requestutils

package
v0.0.0-...-762ab57 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2024 License: MPL-2.0 Imports: 9 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// RequestIDHeaderKey is the request header key
	RequestIDHeaderKey = "x-request-id"
	// RequestID holds the type for request ids
	RequestID = requestID(RequestIDHeaderKey)
	// HostHeaderKey is the request header key
	HostHeaderKey = "host"
	// XForwardedHostHeaderKey is the request header key
	XForwardedHostHeaderKey = "x-forwarded-host"
)

Functions

func GetRequestID

func GetRequestID(ctx context.Context) string

GetRequestID gets the request id

func Read

func Read(ctx context.Context, body io.Reader) ([]byte, error)

Read an io reader

func ReadJSON

func ReadJSON(ctx context.Context, body io.Reader, intr interface{}) error

ReadJSON reads a request body according to an interface and limits the size to 10MB

func ReadWithLimit

func ReadWithLimit(ctx context.Context, body io.Reader, limit int64) ([]byte, error)

ReadWithLimit reads an io reader with a limit and closes

func SetRequestID

func SetRequestID(ctx context.Context, r *http.Request)

SetRequestID transfers a request id from a context to a request header

Types

This section is empty.

Jump to

Keyboard shortcuts

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