package
0.0.0-20241222002135-c9d1db9af773
Repository: https://github.com/alphaone1/midgard.git
Documentation: pkg.go.dev

# README

Access Logging Middleware

The access logging middleware logs each request with the following information:

  • correlationID
  • client address
  • HTTP method
  • path

Example

The access logging will use the default logger slog.Default() and INFO log level.

finalHandler := midgard.StackMiddlewareHandler(
    []midgard.Middleware{
        access_log.New(),
    },
    http.HandlerFunc(HelloHandler),
)

It can also be configured with a custom logger and level.

finalHandler := midgard.StackMiddlewareHandler(
    []midgard.Middleware{
        access_log.New(
            access_log.WithLogger(someOtherLogger),
            access_log.WithLogLevel(slog.LevelDebug),
        ),
    },
    http.HandlerFunc(HelloHandler),
)

# Functions

New generates a new access logging middleware.
WithLogger configures the logger to use.
WithLogLevel configures the log level to use with the logger.

# Structs

Handler holds the information necessary for the log.