package api import ( "fmt" "net/http" "github.com/gin-gonic/gin" "github.com/simpletodoapp/go-todo-app/internal/config" ) // SetupDocs sets up the API documentation func SetupDocs(router *gin.Engine, cfg *config.Config) { // Simple documentation page router.GET("/docs", func(c *gin.Context) { html := fmt.Sprintf(`
%s
Version: %s
GET /health
Check the health of the application and database.
{ "status": "healthy", "db_status": "healthy" }
GET /api/todos
Retrieve a list of todos with optional filtering and pagination.
skip
- Number of items to skip (default: 0)limit
- Maximum number of items to return (default: 100)completed
- Filter by completion status (boolean, optional)[ { "id": 1, "title": "Learn Go", "description": "Learn Go programming language", "completed": false, "created_at": "2023-09-10T12:00:00Z", "updated_at": "2023-09-10T12:00:00Z" } ]
GET /api/todos/:id
Retrieve a specific todo by ID.
id
- Todo ID{ "id": 1, "title": "Learn Go", "description": "Learn Go programming language", "completed": false, "created_at": "2023-09-10T12:00:00Z", "updated_at": "2023-09-10T12:00:00Z" }
POST /api/todos
Create a new todo item.
{ "title": "Learn Go", "description": "Learn Go programming language", "completed": false }
{ "id": 1, "title": "Learn Go", "description": "Learn Go programming language", "completed": false, "created_at": "2023-09-10T12:00:00Z", "updated_at": "2023-09-10T12:00:00Z" }
PUT /api/todos/:id
Update an existing todo.
id
- Todo ID{ "title": "Updated title", // Optional "description": "Updated description", // Optional "completed": true // Optional }
{ "id": 1, "title": "Updated title", "description": "Updated description", "completed": true, "created_at": "2023-09-10T12:00:00Z", "updated_at": "2023-09-10T12:05:00Z" }
DELETE /api/todos/:id
Delete a todo.
id
- Todo IDNo content (HTTP 204)