Documentation
¶
Index ¶
- Constants
- func IgnoreFaviconHandler() http.HandlerFunc
- func IgnoreFaviconRoute() serv.Route
- func Middleware(log Logger, next http.Handler) http.Handler
- func RemoteAddr(r *http.Request) string
- func RequestURI(r *http.Request) string
- func SetShouldIgnore(ctx context.Context, ignore bool) context.Context
- func ShouldIgnore(ctx context.Context) bool
- func Username(r *http.Request) string
- type Details
- type Logger
- type ResponseStatus
Constants ¶
View Source
const Message string = "access request"
Variables ¶
This section is empty.
Functions ¶
func IgnoreFaviconHandler ¶ added in v0.2.0
func IgnoreFaviconHandler() http.HandlerFunc
func IgnoreFaviconRoute ¶ added in v0.2.0
func Middleware ¶
Middleware wraps a http.Handler so it's request and response details are tracked and send to Logger log.
func RemoteAddr ¶
RemoteAddr returns a sanitized remote address from the http.Request.
func RequestURI ¶
RequestURI https://www.rfc-editor.org/rfc/rfc7540#section-8.3
func SetShouldIgnore ¶ added in v0.2.0
func ShouldIgnore ¶ added in v0.2.0
Types ¶
type Details ¶
type Details struct {
ServerName string
HandlerName string
UserAgent string
// StatusCode is the first http response code passed to the
// [http.ResponseWriter.WriteHeader]. See [httpsnoop.Metrics] for additional
// information.
StatusCode int
// StartTime is the time the request was received.
StartTime time.Time
// Duration is the time it took to execute the handler.
Duration time.Duration
// BytesWritten is the number of bytes successfully written by the
// [http.ResponseWriter.Write] or [http.ResponseWriter.ReadFrom] functions.
// See [httpsnoop.Metrics] for additional information.
BytesWritten int64
// RequestCount is the amount of open requests during the execution of the
// handler.
RequestCount int64
}
Details are collected with Middleware and contain additional details of a request and it's corresponding response.
type Logger ¶
func DefaultLogger ¶
func LimitCodes ¶
func LimitCodes(rs ResponseStatus, next Logger) Logger
type ResponseStatus ¶
type ResponseStatus int
const ( ResponseStatusSuccess ResponseStatus = 1 << iota // 200-299 ResponseStatusRedirect // 300-399 ResponseStatusClientError // 400-499 ResponseStatusServerError // 500-599 ResponseStatusNone ResponseStatus = 0 ResponseStatusAll = ResponseStatusSuccess | ResponseStatusRedirect | ResponseStatusClientError | ResponseStatusServerError ResponseStatusErrors = ResponseStatusClientError | ResponseStatusServerError )
func (ResponseStatus) InRange ¶
func (l ResponseStatus) InRange(statusCode int) bool
Click to show internal directories.
Click to hide internal directories.