This is a sample server for a Go web service.
- Go 1.21 or higher
- PostgreSQL
- .env containing : PORT, DB_STRING, SECRET_KEY
- Redirects all endpoint of /swagger/ to swagger/index.html (httpSwagger.handler of
go get github.com/swaggo/http-swagger/v2
)
- Generates API definition from Annotations using swaggo/swag/cmd/swag@latest (
go install github.com/swaggo/swag/cmd/swag@latest
)
$ > swag init ./ --parseDependency
<!-- This will create Swagger API definition in docs/swagger.json -->
<!-- flag parseDependency is used as some endpoints types are not go-predeclared types, they are customized types from sql library for Null Values Detection -->
- Manual testing can be done through swagger 2.0 API documents.
- Chain of Responsibility : Middleware
- Dependency Injection : Singleton database connection + Pgxpool concurrency supported