request

package
v0.0.0-...-a5439fb Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2024 License: AGPL-3.0 Imports: 7 Imported by: 5

Documentation

Index

Constants

View Source
const (
	// HeaderForwardedAddress is the forwarded address field in request header.
	HeaderForwardedAddress = "X-LXD-forwarded-address"

	// HeaderForwardedUsername is the forwarded username field in request header.
	HeaderForwardedUsername = "X-LXD-forwarded-username"

	// HeaderForwardedProtocol is the forwarded protocol field in request header.
	HeaderForwardedProtocol = "X-LXD-forwarded-protocol"

	// HeaderForwardedIdentityProviderGroups is the forwarded identity provider groups field in request header.
	// This will be a JSON marshalled []string.
	HeaderForwardedIdentityProviderGroups = "X-LXD-forwarded-identity-provider-groups"
)

Headers.

Variables

This section is empty.

Functions

func CreateRequestor

func CreateRequestor(r *http.Request) *api.EventLifecycleRequestor

CreateRequestor extracts the lifecycle event requestor data from an http.Request context.

func GetCtxValue

func GetCtxValue[T any](ctx context.Context, key CtxKey) (T, error)

GetCtxValue gets a value of type T from the context using the given key.

func ProjectParam

func ProjectParam(request *http.Request) string

ProjectParam returns the project query parameter from the given request or "default" if parameter is not set.

func QueryParam

func QueryParam(request *http.Request, key string) string

QueryParam extracts the given query parameter directly from the URL, never from an encoded body.

func SaveConnectionInContext

func SaveConnectionInContext(ctx context.Context, connection net.Conn) context.Context

SaveConnectionInContext can be set as the ConnContext field of a http.Server to set the connection in the request context for later use.

func SetCtxValue

func SetCtxValue(r *http.Request, key CtxKey, value any)

SetCtxValue sets the given value in the request context with the given key.

Types

type CtxKey

type CtxKey string

CtxKey is the type used for all fields stored in the request context by LXD.

const (
	// CtxAccess is the access field in request context.
	CtxAccess CtxKey = "access"

	// CtxConn is the connection field in the request context.
	CtxConn CtxKey = "conn"

	// CtxAddress is the address field in request context.
	CtxAddress CtxKey = "address"

	// CtxUsername is the username field in request context.
	CtxUsername CtxKey = "username"

	// CtxProtocol is the protocol field in request context.
	CtxProtocol CtxKey = "protocol"

	// CtxIdentityProviderGroups is the identity provider groups field in the request context.
	// This contains groups defined by the identity provider if the identity authenticated with OIDC.
	CtxIdentityProviderGroups CtxKey = "identity_provider_groups"

	// CtxForwardedAddress is the forwarded address field in request context.
	CtxForwardedAddress CtxKey = "forwarded_address"

	// CtxForwardedUsername is the forwarded username field in request context.
	CtxForwardedUsername CtxKey = "forwarded_username"

	// CtxForwardedProtocol is the forwarded protocol field in request context.
	CtxForwardedProtocol CtxKey = "forwarded_protocol"

	// CtxForwardedIdentityProviderGroups is the identity provider groups field in the request context.
	// This contains groups defined by the identity provider if the identity authenticated with OIDC on another cluster
	// member.
	CtxForwardedIdentityProviderGroups CtxKey = "identity_provider_groups"

	// CtxEffectiveProjectName is used to indicate that the effective project of a resource is different from the project
	// specified in the URL. (For example, if a project has `features.networks=false`, any networks in this project actually
	// belong to the default project).
	CtxEffectiveProjectName CtxKey = "effective_project_name"

	// CtxTrusted is a boolean value that indicates whether the request was authenticated or not.
	CtxTrusted CtxKey = "trusted"

	// CtxMetricsCallbackFunc is a callback function that can be called to mark the request as completed for the API metrics.
	CtxMetricsCallbackFunc CtxKey = "metrics_callback_function"

	// CtxOpenFGARequestCache is used to set a cache for the OpenFGA datastore to improve driver performance on a per request basis.
	CtxOpenFGARequestCache CtxKey = "openfga_request_cache"
)

Context keys.

Jump to

Keyboard shortcuts

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