request

package
v0.0.0-...-2bf1e3b Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

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 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) 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