File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 77 "github.com/andybalholm/brotli"
88 lru "github.com/hashicorp/golang-lru"
99 "go-http-server/param"
10+ "go-http-server/util"
1011 "golang.org/x/exp/slices"
1112 "io"
1213 "mime"
@@ -256,9 +257,16 @@ func (app *App) HandlerFuncNew(w http.ResponseWriter, r *http.Request) {
256257}
257258
258259func (app * App ) Listen () {
260+ var handlerFunc http.Handler = http .HandlerFunc (app .HandlerFuncNew )
261+ if app .params .Logger {
262+ handlerFunc = util .LogRequestHandler (handlerFunc , & util.LogRequestHandlerOptions {
263+ Pretty : app .params .LogPretty ,
264+ })
265+ }
266+
259267 app .server = & http.Server {
260268 Addr : fmt .Sprintf ("%s:%d" , app .params .Address , app .params .Port ),
261- Handler : http . HandlerFunc ( app . HandlerFuncNew ) ,
269+ Handler : handlerFunc ,
262270 }
263271
264272 fmt .Printf ("Server listening on http://%s\n " , app .server .Addr )
You can’t perform that action at this time.
0 commit comments