middleware

package
v0.0.0-...-7a5cd37 Latest Latest
Warning

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

Go to latest
Published: May 7, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const RequestIDHeader string = "X-Request-Id"
View Source
const RequestIDKey ctxKeyRequestID = 0

Variables

This section is empty.

Functions

func GetReqID

func GetReqID(ctx context.Context) string

функция получения request id ранее сохраненного в контексте запроса

func Logger

func Logger(log *slog.Logger) func(next http.Handler) http.Handler

Возращает функцию для организации middleware логера запросов

func RequestID

func RequestID(next http.Handler) http.Handler

middleware получение request id - из строки запроса, иначе: - из заголовка запроса, иначе: - генерация id

Types

type WrapResponseWriter

type WrapResponseWriter interface {
	http.ResponseWriter
	// Status returns the HTTP status of the request, or 0 if one has not
	// yet been sent.
	Status() int
	// BytesWritten returns the total number of bytes sent to the client.
	BytesWritten() int
	// Tee causes the response body to be written to the given io.Writer in
	// addition to proxying the writes through. Only one io.Writer can be
	// tee'd to at once: setting a second one will overwrite the first.
	// Writes will be sent to the proxy before being written to this
	// io.Writer. It is illegal for the tee'd writer to be modified
	// concurrently with writes.
	Tee(io.Writer)
	// Unwrap returns the original proxied target.
	Unwrap() http.ResponseWriter
}

WrapResponseWriter is a proxy around an http.ResponseWriter that allows you to hook into various parts of the response process.

func NewWrapResponseWriter

func NewWrapResponseWriter(w http.ResponseWriter, protoMajor int) WrapResponseWriter

NewWrapResponseWriter wraps an http.ResponseWriter, returning a proxy that allows you to hook into various parts of the response process.

Jump to

Keyboard shortcuts

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