httpd

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddToContext

func AddToContext(ctx context.Context, d Details) context.Context

AddToContext adds the HTTP details to a context.

func Decorator

func Decorator(inner auditrail.Logger) auditrail.Logger

Decorator returns a new audit.Logger that appends http details to the log entry before logging it.

This decorator assumes that http data was previously added to the context using the AddToContext function, either directly or through some of the provided middlewares (Gin, Echo, etc).

func EchoMiddleware

func EchoMiddleware(next echo.HandlerFunc) echo.HandlerFunc

EchoMiddleware is an Echo middleware that injects into request's context a httpd.Details object holding request details.

func GRPCStreamInterceptor

func GRPCStreamInterceptor(srv interface{}, ss grpc.ServerStream, ssi *grpc.StreamServerInfo, handler grpc.StreamHandler) error

GRPCStreamInterceptor is a gRPC stream server interceptor that injects httpd.Details into the context.

func GRPCUnaryInterceptor

func GRPCUnaryInterceptor(ctx context.Context, req interface{}, usi *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (resp interface{}, err error)

GRPCUnaryInterceptor is a gRPC unary call interceptor that injects httpd.Details into the context.

func GinMiddleware

func GinMiddleware(c *gin.Context)

GinMiddleware is a Gin middleware that injects into request's context a httpd.Details object holding request details.

Types

type Details

type Details struct {
	Method     string `json:"method"`
	StatusCode string `json:"status_code"`
	UserAgent  string `json:"user_agent"`
	URL        URL    `json:"url"`
}

Details represents the details of an HTTP request.

func FromContext

func FromContext(ctx context.Context) Details

FromContext extracts the HTTP details from a context.

func (Details) IsEmpty

func (d Details) IsEmpty() bool

IsEmpty returns true if the details are empty.

type URL

type URL struct {
	Host string `json:"host"`
	Path string `json:"path"`
}

URL HTTP request url details.

Jump to

Keyboard shortcuts

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