https://ec2-52-77-251-29.ap-southeast-1.compute.amazonaws.com
This document outlines the RESTful API endpoints for [Your Server Name]. The server is built using the Gin framework in Go and interacts with a MySQL database.
All API endpoints are relative to the base URL: /api
- Path:
/api/u/signup
- Method: POST
- Body:
{ "username": "user123", "password_hash": "hashedpassword" }
- Example Request (cURL):
curl -X POST https://ec2-52-77-251-29.ap-southeast-1.compute.amazonaws.com/api/u/signup \ -H 'Content-Type: application/json' \ -d '{"username": "user123", "password_hash": "hashedpassword"}'
- Response:
- Success: Status code 200 with user details
- Error: Status code 4xx/5xx with error message
- Path:
/api/u/login
- Method: POST
- Body:
{ "username": "user123", "password_hash": "hashedpassword" }
- Example Request (cURL):
curl -X POST https://ec2-52-77-251-29.ap-southeast-1.compute.amazonaws.com/api/u/login \ -H 'Content-Type: application/json' \ -d '{"username": "user123", "password_hash": "hashedpassword"}'
- Response:
- Success: Status code 200 with JWT token
- Error: Status code 401 for unauthorized access
- Path:
/api/u/
- Method: DELETE
- Auth Required: Yes
- Example Request (cURL):
curl -X DELETE https://ec2-52-77-251-29.ap-southeast-1.compute.amazonaws.com/api/u/ \ -H 'Authorization: Bearer [JWT Token]' \
- Response:
- Success: Status code 200 with JWT token
- Error: Status code 401 for unauthorized access
- Path:
/api/p/
- Method: POST
- Auth Required: Yes
- Body:
{ "title": "Sample Title", "body": "This is a sample post." }
- Example Request (cURL):
curl -X POST https://ec2-52-77-251-29.ap-southeast-1.compute.amazonaws.com/api/p/ \ -H 'Authorization: Bearer [JWT Token]' \ -H 'Content-Type: application/json' \ -d '{"title": "Sample Title", "body": "This is a sample post."}'
- Response:
- Success: Status code 200 with created post details
- Error: Status code 4xx/5xx with error message
- Path:
/api/p/:post_id/like
- Method: POST
- Auth Required: Yes
- Example Request (cURL):
(where 123 is the post_id)
curl -X POST https://ec2-52-77-251-29.ap-southeast-1.compute.amazonaws.com/api/p/123/like \ -H 'Authorization: Bearer [JWT Token]'
- Response:
- Success: Status code 200 with updated like status
- Error: Status code 4xx/5xx with error message
- Path:
/api/p/:post_id/unlike
- Method: POST
- Auth Required: Yes
- Example Request (cURL):
(where 123 is the post_id)
curl -X POST https://ec2-52-77-251-29.ap-southeast-1.compute.amazonaws.com`/api/p/123/unlike \ -H 'Authorization: Bearer [JWT Token]'
- Response:
- Success: Status code 200 with updated like status
- Error: Status code 4xx/5xx with error message
4xx
: Client errors (e.g., bad request, unauthorized, not found)5xx
: Server errors (e.g., internal server error)