The main purpose of this repository is to collect code that can be reused in one or more applications in order to speed up their development.
Entry point for gin configuration is NewGin function.
Configuration can be done via next environment variables:
- GIN_MODE - debug/release/test
- GIN_TEMPLATES_MODE - debug/release (if the variable is not set, templates are not loaded)
- GIN_TEMPLATES_PATH - absolute/relative path to html templates
- ENABLE_PPROF - enable/disable golang profiler on path /system/pprof
- ENABLE_PROMETHEUS - enable/disable gin metrics for prometheus on path /system/prometheus
- ENABLE_OPENAPI - enable/disable openapi schema on path /system/openapi
A small object that makes it easier to work with html templates in gin. You can do without it if you don't need to render any html at all.
A small hack to add openapi specification file to /system/openapi.
How to use it:
- Set environment variable
ENABLE_OPENAPI=true
- Add the following lines to your project:
//go:embed api.yml
var openAPIData []byte
- Point sfutils to this variable:
sfutils.SetOpenAPIData(openAPIData)
go tool pprof 'user:password@127.0.0.1:8080/system/pprof/heap'
go tool pprof 'user:password@127.0.0.1:8080/system/pprof/profile?seconds=30'