This is a RESTful API framework built in Golang that is hopefully well designed for
quick development and easy maintainability. It will work with dependencies made
available in the repository github.com/doublehops/dhapi.
The basic requirements from a RESTful API framework are:
parameters in URL - such asapi/user/123easy validationdatabase integrationdatabase migrationspaginationincludesparameter to include related models in response.ability to include prebuilt and custom middlewareeasy filtering in collection requestssorting and ordering in collection requestsCRUD scaffolding- user model, login and authentication, etc...
- ci/cd
- documentation
Good to have:
- command line tool to list endpoints
./cmd/api/main.go# Start API service./cmd/migrate/migrate.go# Run database migrations./internal/routes/# Contains definitions of API routes. One file per model./internal/handlers/# Contains handlers for incoming API requests./internal/models/# Contain data models./internal/service/# Service layer that contains business logic of each model/endpoints./internal/repository/# Contains data retrieval functions./internal/migrations/# Contains database migration files./internal/middleware/# Contains API middleware./config.json# Application configuration
Scaffolding is a tool that will read the table definition in the database and create the CRUD routes, handlers, service and repository layers so that you can get started creating the new endpoints for a new model much faster than creating each file manually. Make sure the database is running and app database settings configured.
To run:
make scaffold -table=<table_name>