requests

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2021 License: MPL-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewRequestContext

func NewRequestContext(parent context.Context, opt ...Option) context.Context

NewRequestContext returns a derived context with a new RequestContext value added in.

func OutputFields

func OutputFields(ctx context.Context) (perms.OutputFieldsMap, bool)

OutputFields returns output fields from the given context and calls SelfOrDefaults on it. If the context does not contain a RequestContext, this will return nil, false.

Types

type ContextRequestInformation

type ContextRequestInformation struct{}

ContextRequestInforation is a type used solely for context keys -- see the variable below

var ContextRequestInformationKey ContextRequestInformation

ContextRequestInformationKey is a value to keep linters from complaining about clashing identifiers

type Option

type Option func(*options)

Option - how Options are passed as arguments. Some of these are used for types within the handlers package, and some are for handlers to re-use across the various handler types.

func WithUserId

func WithUserId(userId string) Option

WithUserId specifies a user ID with which to populate the returned RequestContext

type RequestContext

type RequestContext struct {
	// Method is the method of the request
	Method string

	// Path is the path of the request
	Path string

	// UserId contains the final discovered user ID
	UserId string

	// OutputFields is the set of fields authorized for output for the
	// authorized action, if not the default
	OutputFields perms.OutputFieldsMap
}

RequestContext is used to propagate request information. It can be updated at various points, e.g. UserId would be updated via the result of auth.Verify.

It serves as a struct to gather information we learn about the request as it goes along. This is distinct from options handling; none of the fields here are "optional" and should all eventually be populated as the request moves through the system.

func RequestContextFromCtx

func RequestContextFromCtx(ctx context.Context) (*RequestContext, bool)

RequestContextFromCtx pulls out RequestContext and returns it and an indication it was found. If it's not found, nil will be returned and the bool will be false.

Jump to

Keyboard shortcuts

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