middleware

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2025 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ErrorHandler

func ErrorHandler(next http.Handler) http.Handler

ErrorHandler middleware processes any errors set during request handling

func GetRequestID

func GetRequestID(ctx context.Context) string

func RequestID

func RequestID(next http.Handler) http.Handler

func RequestLogger

func RequestLogger(next http.Handler) http.Handler

RequestLogger is a middleware that logs HTTP requests using zerolog

func SetBadRequestError

func SetBadRequestError(r *http.Request, err error)

func SetError

func SetError(r *http.Request, status int, err error)

SetError stores an error in the request context

func SetInternalError

func SetInternalError(r *http.Request, err error)

func SetNotFoundError

func SetNotFoundError(r *http.Request, err error)

func SetUnauthorizedError

func SetUnauthorizedError(r *http.Request, err error)

Types

type ErrorResponse

type ErrorResponse struct {
	Error string `json:"error"`
	Code  int    `json:"code"`
}

ErrorResponse represents the standard error response

type RequestError

type RequestError struct {
	Status     int
	Err        error
	IsInternal bool
}

RequestError holds the error information for a request

Jump to

Keyboard shortcuts

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