context

package
v0.13.2 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2025 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMissingBodyInContext = errors.New("missing body in context")
	ErrInvalidBodyType      = errors.New("invalid body type in context")
)

Functions

func GetBody added in v0.11.2

func GetBody(r *http.Request) any

GetBody wraps GetCtxBody

func GetCtxBody

func GetCtxBody(r *http.Request) any

GetCtxBody tries to get the body from the context

Parameters:

  • r: The HTTP request

Returns:

  • any: The body from the context, or nil if not found

func GetCtxQueryParameters added in v0.11.2

func GetCtxQueryParameters(r *http.Request) map[string][]string

GetCtxQueryParameters tries to get the query parameters from the context

Parameters:

  • r: The HTTP request

Returns:

  • map[string][]string: The query parameters from the context, or nil if not found

func GetCtxWildcards added in v0.11.2

func GetCtxWildcards(r *http.Request) map[string]string

GetCtxWildcards tries to get the wildcards from the context

Parameters:

  • r: The HTTP request

Returns:

  • map[string]string: The wildcards from the context, or nil if not found

func GetQueryParameters added in v0.11.2

func GetQueryParameters(r *http.Request) map[string][]string

GetQueryParameters wraps GetCtxQueryParameters

func GetWildcards added in v0.11.2

func GetWildcards(r *http.Request) map[string]string

GetWildcards wraps GetCtxWildcards

func SetBody added in v0.11.2

func SetBody(r *http.Request, body any) *http.Request

SetBody wraps SetCtxBody

func SetCtxBody

func SetCtxBody(r *http.Request, body any) *http.Request

SetCtxBody sets the body in the context

Parameters:

  • r: The HTTP request
  • body: The body to set in the context

Returns:

  • *http.Request: The HTTP request with the body set in the context

func SetCtxQueryParameters added in v0.11.2

func SetCtxQueryParameters(
	r *http.Request,
	parameters map[string][]string,
) *http.Request

SetCtxQueryParameters sets the query parameters in the context

Parameters:

  • r: The HTTP request
  • parameters: The query parameters to set in the context

Returns:

  • *http.Request: The HTTP request with the query parameters set in the context

func SetCtxWildcards added in v0.11.2

func SetCtxWildcards(
	r *http.Request,
	wildcards map[string]string,
) *http.Request

SetCtxWildcards sets the wildcards in the context

Parameters:

  • r: The HTTP request
  • wildcards: The wildcards to set in the context

Returns:

  • *http.Request: The HTTP request with the wildcards set in the context

func SetQueryParameters added in v0.11.2

func SetQueryParameters(
	r *http.Request,
	parameters map[string][]string,
) *http.Request

SetQueryParameters wraps SetCtxQueryParameters

func SetWildcards added in v0.11.2

func SetWildcards(
	r *http.Request,
	wildcards map[string]string,
) *http.Request

SetWildcards wraps SetCtxWildcards

Types

type ContextKey added in v0.12.7

type ContextKey string

ContextKey is the type for context keys

const (
	// CtxBodyKey is the context key for the body
	CtxBodyKey ContextKey = "body"

	// CtxQueryParametersKey is the context key for the query parameters
	CtxQueryParametersKey ContextKey = "query_parameters"

	// CtxWildcardsKey is the context key for the wildcard
	CtxWildcardsKey ContextKey = "wildcards"
)

Jump to

Keyboard shortcuts

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