logger

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// RequestComponent is a Compogo component that provides request logging middleware.
	RequestComponent = &component.Component{
		Init: component.StepFunc(func(container container.Container) error {
			return container.Provide(NewRequest)
		}),
	}

	// ResponseComponent is a Compogo component that provides response logging middleware.
	ResponseComponent = &component.Component{
		Init: component.StepFunc(func(container container.Container) error {
			return container.Provide(NewResponse)
		}),
	}
)

Functions

This section is empty.

Types

type Request

type Request struct {
	// contains filtered or unexported fields
}

Request is middleware that logs HTTP request bodies at DEBUG level. It reads the entire body, logs it, and restores it for the next handler.

func NewRequest

func NewRequest(logger logger.Logger) *Request

NewRequest creates a new Request logging middleware.

func (*Request) Middleware

func (r *Request) Middleware(next http.Handler) http.Handler

Middleware implements the http.Middleware interface. It reads the request body, logs it, and restores it for subsequent handlers. If body reading fails, it returns 400 Bad Request.

type Response

type Response struct {
	// contains filtered or unexported fields
}

Response is middleware that logs HTTP response bodies at DEBUG level. Useful for debugging API responses in development environments.

func NewResponse

func NewResponse(logger logger.Logger) *Response

NewResponse creates a new Response logging middleware.

func (*Response) Middleware

func (r *Response) Middleware(next http.Handler) http.Handler

Middleware implements the http.Middleware interface. It captures the response body and logs it after the handler completes.

Jump to

Keyboard shortcuts

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