No description
  • Go 95%
  • Bru 3.8%
  • Makefile 0.7%
  • Dockerfile 0.5%
Find a file
2025-06-20 15:53:15 +03:00
bruno use camel case in responses 2025-05-31 15:03:38 +03:00
config first commit 2025-05-31 09:56:55 +03:00
database dev: setup stricter linting 2025-06-04 16:50:30 +03:00
middleware fix: each request has the same requestId 2025-06-20 15:53:15 +03:00
models test: do not user middleware in service tests 2025-06-17 23:00:02 +03:00
services test: do not user middleware in service tests 2025-06-17 23:00:02 +03:00
util test: add test for error middleware 2025-06-17 23:01:36 +03:00
.air.toml dev: fater server restart using by air 2025-06-07 22:34:54 +03:00
.dockerignore first commit 2025-05-31 09:56:55 +03:00
.env.example first commit 2025-05-31 09:56:55 +03:00
.gitignore first commit 2025-05-31 09:56:55 +03:00
.golangci.yml lint: add more linter rules 2025-06-17 23:02:19 +03:00
dev.compose.yml dev: colorize docker logs 2025-06-07 22:35:04 +03:00
Dockerfile first commit 2025-05-31 09:56:55 +03:00
go.mod manually clean up go.mod 2025-06-07 22:43:01 +03:00
go.sum run go mod tidy 2025-06-07 22:37:00 +03:00
main.go fix: each request has the same requestId 2025-06-20 15:53:15 +03:00
Makefile first commit 2025-05-31 09:56:55 +03:00
Readme.md dev: setup stricter linting 2025-06-04 16:50:30 +03:00

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.