ࣗਝযҗ 3֙ / Backend Developer Blog https://mingrammer.com Facebook https://facebook.com/mingrammer Github https://github.com/mingrammer Eng Blog https://medium.com/@mingrammer
projects • POST : Create a new project /projects/:title • GET : Get a project • PUT : Update a project • DELETE : Delete a project /projects/:title/archive • PUT : Archive a project • DELETE : Restore a project Projects API Design
tasks of a project • POST : Create a new task in a project /projects/:title/tasks/:id • GET : Get a project of a project • PUT : Update a project of a project • DELETE : Delete a project of a project /projects/:title/tasks/:id/complete • PUT : Archive a project of a project • DELETE : Restore a project of a project Tasks API Design
projects • POST : Create a new project /projects/:title • GET : Get a project • PUT : Update a project • DELETE : Delete a project /projects/:title/archive • PUT : Archive a project • DELETE : Restore a project /projects/:title/tasks • GET : Get all tasks of a project • POST : Create a new task in a project /projects/:title/tasks/:id • GET : Get a project of a project • PUT : Update a project of a project • DELETE : Delete a project of a project /projects/:title/tasks/:id/complete • PUT : Archive a project of a project • DELETE : Restore a project of a project API Design
├── handler │ │ ├── common.go │ │ ├── projects.go │ │ └── tasks.go │ └── model │ └── model.go ├── config │ └── config.go └── main.go Application Structure Our API core handlers Common response functions APIs for Project model APIs for Task model Models for our application Configuration Init, route and run the app
├── handler │ │ ├── common.go │ │ ├── projects.go │ │ └── tasks.go │ └── model │ └── model.go ├── config │ └── config.go └── main.go app/app.go Initialize the app Set all routers to app Register all handlers to app Run the app
/projects/:title/tasks/:id : Get a task of a project PUT : /projects/:title/tasks/:id: Update a task of a project DELETE : /projects/:title/tasks/:id : Delete a task of a project handler/tasks.go
: /projects/:title/tasks/:id : Get a task of a project PUT : /projects/:title/tasks/:id: Update a task of a project DELETE : /projects/:title/tasks/:id : Delete a task of a project handler/tasks.go
/projects/:title/tasks/:id/complete : Complete a task of a project DELETE : /projects/:title/tasks/:id/complete : Undo a task of a project handler/tasks.go
├── common.go │ │ ├── projects.go │ │ └── tasks.go │ └── model │ └── model.go ├── config │ └── config.go └── main.go Implementation of REST API model/model.go Define the model structs with Gorm Provide some methods of models Provide a DB migration function