Documentation ¶
Overview ¶
Package loghttp exposes a http.Handler that logs requests via log.Printf().
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Handler ¶
Handler wraps a http.Handler and logs the request and response.
It handles Hijack() for websocket support.
Example ¶
package main import ( "log" "net/http" "time" "github.com/maruel/serve-dir/loghttp" ) func main() { // Serves the current directory over HTTP and logs all requests. log.SetFlags(log.Lmicroseconds) s := &http.Server{ Addr: ":6060", Handler: &loghttp.Handler{Handler: http.FileServer(http.Dir("."))}, ReadTimeout: 10. * time.Second, WriteTimeout: 24 * 60 * 60 * time.Second, MaxHeaderBytes: 256 * 1024 * 1024 * 1024, } log.Fatal(s.ListenAndServe()) }
Output:
Click to show internal directories.
Click to hide internal directories.