add flag (-http-log) to disable http request logging

This commit is contained in:
Duncan Overbruck
2021-02-27 16:27:59 +01:00
committed by Senan Kelly
parent 7d420f61a9
commit 2a11017d54
2 changed files with 6 additions and 1 deletions

View File

@@ -37,6 +37,7 @@ func main() {
confJukeboxEnabled := set.Bool("jukebox-enabled", false, "whether the subsonic jukebox api should be enabled (optional)")
confProxyPrefix := set.String("proxy-prefix", "", "url path prefix to use if behind proxy. eg '/gonic' (optional)")
confGenreSplit := set.String("genre-split", "\n", "character or string to split genre tag data on (optional)")
confHTTPLog := set.Bool("http-log", true, "http request logging (optional)")
confShowVersion := set.Bool("version", false, "show gonic version")
_ = set.String("config-path", "", "path to config (optional)")
@@ -99,6 +100,7 @@ func main() {
ProxyPrefix: *confProxyPrefix,
GenreSplit: *confGenreSplit,
PodcastPath: *confPodcastPath,
HTTPLog: *confHTTPLog,
})
var g run.Group

View File

@@ -32,6 +32,7 @@ type Options struct {
CoverCachePath string
ProxyPrefix string
GenreSplit string
HTTPLog bool
}
type Server struct {
@@ -60,7 +61,9 @@ func New(opts Options) *Server {
}
// router with common wares for admin / subsonic
r := mux.NewRouter()
r.Use(base.WithLogging)
if opts.HTTPLog {
r.Use(base.WithLogging)
}
r.Use(base.WithCORS)
//
sessKey := opts.DB.GetOrCreateKey("session_key")