On this series, we gonna build the REST API with Golang. As a basis, we'll be using Goyave. Goyave is an opinionated Golang REST API framework aiming at cleanliness, fast development and power. Goyave applications stay clean and concise thanks to minimalist function calls and route handlers. The framework gives you all the tools to create an easily readable and maintainable web applications, which let you concentrate on the business logic. Although Goyave is a full package requiring very few setup and that handles many things for you, such as headers or marshaling, this characteristic doesn't compromise on your freedom of code.
You can read more about goyave framework from here: https://goyave.dev/
As an example, we'll be build blog API. The requirements is:
- Go 1.16+
- Go modules
the directory structure
.
├── database
│ ├── model // ORM models
│ | └── ...
│ └── seeder // Generators for database testing
│ └── ...
├── http
│ ├── controller // Business logic of the application
│ │ └── ...
│ ├── middleware // Logic executed before or after controllers
│ │ └── ...
│ ├── validation
│ │ └── validation.go // Custom validation rules
│ └── route
│ └── route.go // Routes definition
│
├── resources
│ └── lang
│ └── en-US // Overrides to the default language lines
│ ├── fields.json
│ ├── locale.json
│ └── rules.json
│
├── test // Functional tests
| └── ...
|
├── .gitignore
├── .golangci.yml // Settings for the Golangci-lint linter
├── config.example.json // Example config for local development
├── config.test.json // Config file used for tests
├── go.mod
└── main.go // Application entrypoint
0 comments:
Post a Comment