[feature] Gin enable gzip encoding (#405)

* add gin gzip dependency

* add gzip middleware to router

* go mod tidy
This commit is contained in:
tobi
2022-02-19 12:12:41 +01:00
committed by GitHub
parent 23034ec145
commit a089a98ea9
11 changed files with 442 additions and 5 deletions

View File

@ -137,11 +137,8 @@ func New(ctx context.Context, db db.DB) (Router, error) {
return nil, err
}
// set template functions
LoadTemplateFunctions(engine)
// load templates onto the engine
if err := loadTemplates(engine); err != nil {
// enable gzip compression on the engine
if err := useGzip(engine); err != nil {
return nil, err
}
@ -150,6 +147,14 @@ func New(ctx context.Context, db db.DB) (Router, error) {
return nil, err
}
// set template functions
LoadTemplateFunctions(engine)
// load templates onto the engine
if err := loadTemplates(engine); err != nil {
return nil, err
}
// create the http server here, passing the gin engine as handler
bindAddress := viper.GetString(keys.BindAddress)
port := viper.GetInt(keys.Port)