echo

command
v1.0.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 28, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

README

API Usage

Create tenant

  • Parse the request body into a CreateTenantBody struct
  • Create the tenant in the database (public schema)
  • Create the schema for the tenant
  • Return the HTTP status code 201 and the tenant in the response body
Request
curl -X POST \
  http://example.com:8080/tenants \
  -H 'Content-Type: application/json' \
  -d '{
  "domainUrl": "tenant3.example.com"
}'
Response
{
  "id": 3,
  "domainUrl": "tenant3.example.com"
}

Get tenant

  • Get the tenant from the database
  • Return the HTTP status code 200 and the tenant in the response body
Request
curl -X GET \
  http://example.com:8080/tenants/3
Response
{
  "id": 3,
  "domainUrl": "tenant3.example.com"
}

Delete tenant

  • Get the tenant from the database
  • Delete the schema for the tenant
  • Delete the tenant from the database
  • Return the HTTP status code 204
Request
curl -X DELETE \
  http://example.com:8080/tenants/3
Response

Get books

  • Get the tenant from the request host or header
  • Get all books for the tenant
  • Return the HTTP status code 200 and the books in the response body
Request
curl -X GET \
  http://example.com:8080/books \
  -H 'Host: tenant1.example.com'
Response
[
  {
    "id": 1,
    "name": "Book 1"
  },
  {
    "id": 2,
    "name": "Book 2"
  }
]

Create book

  • Get the tenant from the request host or header
  • Parse the request body into a Book struct
  • Create the book for the tenant in the database
  • Return the HTTP status code 201 and the book in the response body
Request
curl -X POST \
  http://example.com:8080/books \
  -H 'Content-Type: application/json' \
  -H 'Host: tenant1.example.com' \
  -d '{
  "name": "Book 3"
}'
Response
{
  "id": 3,
  "name": "Book 3"
}

Delete book

  • Get the tenant from the request host or header
  • Get the book from the database
  • Delete the book from the database
  • Return the HTTP status code 204
Request
curl -X DELETE \
  http://example.com:8080/books/3 \
  -H 'Host: tenant1.example.com'
Response

Update book

  • Get the tenant from the request host or header
  • Get the book from the database
  • Parse the request body into a UpdateBookBody struct
  • Update the book in the database
  • Return the HTTP status code 200
Request
curl -X PUT \
  http://example.com:8080/books/2 \
  -H 'Content-Type: application/json' \
  -H 'Host: tenant1.example.com' \
  -d '{
  "name": "Book 2 updated"
}'
Response

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL