reqlog

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2021 License: MIT Imports: 7 Imported by: 34

README

Request logging middleware for bunrouter

To install:

go get github.com/uptrace/bunrouter/extra/reqlog

To use:

import "github.com/uptrace/bunrouter/extra/reqlog"

router := bunrouter.New(
    bunrouter.WithMiddleware(reqlog.NewMiddleware()),
)

With options:

import "github.com/uptrace/bunrouter/extra/reqlog"

reqlogMiddleware := reqlog.NewMiddleware(reqlog.WithVerbose(false))

router := bunrouter.New(
    bunrouter.WithMiddleware(reqlogMiddleware),
)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewMiddleware

func NewMiddleware(opts ...Option) bunrouter.MiddlewareFunc

Types

type Option

type Option func(m *middleware)

func FromEnv

func FromEnv(key string) Option

WithEnv configures the middleware using the environment variable value. For example, WithEnv("BUNDEBUG"):

  • BUNDEBUG=0 - disables the middleware.
  • BUNDEBUG=1 - enables the middleware.
  • BUNDEBUG=2 - enables the middleware and verbose mode.

func WithEnabled

func WithEnabled(on bool) Option

WithEnabled enables/disables the middleware.

func WithVerbose

func WithVerbose(on bool) Option

WithVerbose configures the middleware to log all requests.

Jump to

Keyboard shortcuts

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