- 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
curl -X POST \
http://example.com:8080/tenants \
-H 'Content-Type: application/json' \
-d '{
"domainUrl": "tenant3.example.com"
}'
{
"id": 3,
"domainUrl": "tenant3.example.com"
}
- Get the tenant from the database
- Return the HTTP status code 200 and the tenant in the response body
curl http://example.com:8080/tenants/3
{
"id": 3,
"domainUrl": "tenant3.example.com"
}
- Get the tenant from the database
- Delete the schema for the tenant
- Delete the tenant from the database
- Return the HTTP status code 204
curl -X DELETE \
http://example.com:8080/tenants/3
- 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
curl http://example.com:8080/books \
-H 'Host: tenant1.example.com'
[
{
"id": 1,
"name": "tenant1 - Book 1"
},
{
"id": 2,
"name": "tenant1 - Book 2"
}
]
- 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
curl -X POST \
http://example.com:8080/books \
-H 'Content-Type: application/json' \
-H 'Host: tenant1.example.com' \
-d '{
"name": "tenant1 - Book 3"
}'
{
"id": 3,
"name": "tenant1 - Book 3"
}
- 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
curl -X DELETE \
http://example.com:8080/books/3 \
-H 'Host: tenant1.example.com'
- 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
curl -X PUT \
http://example.com:8080/books/2 \
-H 'Content-Type: application/json' \
-H 'Host: tenant1.example.com' \
-d '{
"name": "tenant1 - Book 2 - Updated"
}'