Documentation
¶
Overview ¶
Package reqlog implements a middleware around HTTP request logging.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewMiddleware ¶
NewMiddleware returns a middleware that logs HTTP requests.
Example ¶
package main
import (
"net/http"
"codeberg.org/kema/kmicro/pkg/http/middleware/reqlog"
"codeberg.org/kema/kmicro/pkg/http/router"
)
func main() {
r := router.New()
r.Use(reqlog.NewMiddleware())
// curl -v localhost:8080/
r.HandleFunc("GET /", func(w http.ResponseWriter, _ *http.Request) {
_, _ = w.Write([]byte("Hello, World!"))
})
_ = http.ListenAndServe("[::]:8080", r.Compile())
}
Output:
Types ¶
type Option ¶
type Option func(*config)
Option configures HTTP request logging middleware.
func WithLogClientAddr ¶
WithLogClientAddr sets whether to log remote client address.
func WithLogRawURL ¶
WithLogRawURL sets whether to log HTTP request raw URL.
func WithLogUserAgent ¶
WithLogUserAgent sets whether to log user agent.
Click to show internal directories.
Click to hide internal directories.