reqlog

package
v1.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 31, 2026 License: MPL-2.0 Imports: 4 Imported by: 0

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

func NewMiddleware(opts ...Option) func(http.Handler) http.Handler

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())
}

func WrapHandler

func WrapHandler(next http.Handler, opts ...Option) http.Handler

WrapHandler wraps next with request logging.

Types

type Option

type Option func(*config)

Option configures HTTP request logging middleware.

func WithLogClientAddr

func WithLogClientAddr(log bool) Option

WithLogClientAddr sets whether to log remote client address.

func WithLogRawURL

func WithLogRawURL(raw bool) Option

WithLogRawURL sets whether to log HTTP request raw URL.

func WithLogUserAgent

func WithLogUserAgent(log bool) Option

WithLogUserAgent sets whether to log user agent.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL