No description
- Go 95%
- Bru 3.8%
- Makefile 0.7%
- Dockerfile 0.5%
| bruno | ||
| config | ||
| database | ||
| middleware | ||
| models | ||
| services | ||
| util | ||
| .air.toml | ||
| .dockerignore | ||
| .env.example | ||
| .gitignore | ||
| .golangci.yml | ||
| dev.compose.yml | ||
| Dockerfile | ||
| go.mod | ||
| go.sum | ||
| main.go | ||
| Makefile | ||
| Readme.md | ||
Golan HTTP Server Template
This template contains my preferred way of building a monolith HTTP server.
The template is a small TODO app to give an example for how to write handlers and database logic. But, this repo is meant as a base for a larger server.
The core focus points are:
- http.ServeMux wrapper that implements centralized error handling
- proper request validation and human readable validation errors
- automatic SQL up migration on server startup
- proper logging
- log each request including method, url, duration, status code
- when logging from endpoint handlers, a request ID may be automatically attached to logs
- log format and level depends on environment (production vs development)
- unit testing can be done against real database by utilizing testcontainers
For linting I've opted to enable all possible golangci linters,
with the intention to disable any linter that I deem unnecessary,
as I continue to work on with this template. This is easier than
trying to figure out which of the ~100 linters I need to enable.