all repos — elgit @ 878a52408ce37668d57284a344102e810b44b63e

fork of legit: web frontend for git, written in go

add config options for atreugo

Alan Pearce
commit

878a52408ce37668d57284a344102e810b44b63e

parent

5cbb4fc46c7a909a0491f4aa8b841177c3de5929

3 files changed, 25 insertions(+), 19 deletions(-)

changed files
M config/config.goconfig/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 readmereadme
@@ -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.goroutes/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 {