add config options for atreugo
3 files changed, 25 insertions(+), 19 deletions(-)
changed files
M config/config.go → config/config.go
@@ -20,9 +20,11 @@ Description string `yaml:"description"` } type Server struct { - Name string `yaml:"name,omitempty"` - Host string `yaml:"host"` - Port int64 `yaml:"port"` + Name string `yaml:"name,omitempty"` + Host string `yaml:"host"` + Port int64 `yaml:"port"` + Compress bool `yaml:"compress"` + Development bool `yaml:"development"` } type Config struct {
M readme → readme
@@ -47,6 +47,8 @@ server: name: git.icyphox.sh host: 127.0.0.1 port: 5555 + compress: true + development: false These options are fairly self-explanatory, but of note are:@@ -56,6 +58,7 @@ • repo.readme: readme files to look for. • repo.mainBranch: main branch names to look for. • repo.unlisted: repos to hide, relative to root/repositories. • server.name: used for go-import meta tags and clone URLs. +• server.compress: automatically compress responses with gzip or zstd NOTES
M routes/handler.go → routes/handler.go
@@ -33,25 +33,26 @@ repos: &data.Entries{}, } addr := net.JoinHostPort(c.Server.Host, strconv.FormatInt(c.Server.Port, 10)) - srv := atreugo.New(atreugo.Config{ - Addr: addr, - Name: c.Server.Name, - Network: "tcp6", - Prefork: false, - Reuseport: false, - GracefulShutdown: true, - Compress: true, - Logger: log.Default(), - NotFoundView: d.NotFound, - MethodNotAllowedView: nil, - ErrorView: d.Error, - // PanicView: d.Panic, + cfg := atreugo.Config{ + Addr: addr, + Name: c.Server.Name, + Network: "tcp6", + Compress: c.Server.Compress, + Logger: log.Default(), + NotFoundView: d.NotFound, + MethodNotAllowedView: nil, + ErrorView: d.Error, + PanicView: d.Panic, ReadTimeout: 5 * time.Second, DisablePreParseMultipartForm: true, - KeepHijackedConns: false, - CloseOnShutdown: true, + GracefulShutdown: !c.Server.Development, + CloseOnShutdown: !c.Server.Development, StreamRequestBody: true, - }) + } + if c.Server.Development { + cfg.PanicView = nil + } + srv := atreugo.New(cfg) watcher, err := fsnotify.NewWatcher() if err != nil {