request

package
v0.0.0-...-e9a390c Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2026 License: Apache-2.0 Imports: 13 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Put

func Put(r *Request)

Put cleans up and returns a Request to the pool.

Types

type HTTPError

type HTTPError struct {
	Status   int
	Response string
	Err      error
}

func (*HTTPError) Error

func (h *HTTPError) Error() string

func (*HTTPError) ServeError

func (h *HTTPError) ServeError(w http.ResponseWriter)

type Request

type Request struct {
	Context context.Context
	ID      uint64
	Request *http.Request

	Log *slog.Logger
	// contains filtered or unexported fields
}

func Get

func Get(
	w http.ResponseWriter,
	req *http.Request,
	l *slog.Logger,
) *Request

Get acquires a Request from the pool and initializes it.

func New

func New(
	w http.ResponseWriter,
	req *http.Request,
	l *slog.Logger,
) (
	r Request,
)

func (*Request) AccessLog

func (r *Request) AccessLog(l *slog.Logger)

Logs the access log for this request to the given logger.

func (*Request) AddTracer

func (r *Request) AddTracer()

Enables tracing on this Request.

func (*Request) HashHeader

func (r *Request) HashHeader() string

Returns a validated Hash header from the Request.

func (*Request) Header

func (r *Request) Header() http.Header

Returns the underlying response headers to the caller.

func (*Request) Logger

func (r *Request) Logger() *slog.Logger

Logger returns the logger enriched with the request ID, instantiating it lazily if it has not yet been initialized.

func (*Request) PanicHandler

func (r *Request) PanicHandler(serveError bool)

Panic handler. This can be called in a defer from the main request handler in order to catch and return panics raised as part of event flow processing.

If a panic is received then this will sent a HTTP response to the caller indicating what type of error was received (if HTTPError) or a 500 indicating that a completely unexpected error happened during the request processing cycle.

func (*Request) Tracer

func (r *Request) Tracer() *tracing.Trace

Returns the tracer set using AddTracer()

func (*Request) Uint64Header

func (r *Request) Uint64Header(h string) uint64

Gets a header that is expected to be a uint64 value, returning an error if the header is either not present, or can not be parsed into a uint64 value.

func (*Request) Write

func (r *Request) Write(data []byte) (n int, err error)

Writes data to the caller.

func (*Request) WriteHeader

func (r *Request) WriteHeader(h int)

Writes a status code to to the caller.

Jump to

Keyboard shortcuts

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