request

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func UserFrom

func UserFrom(ctx context.Context) (user.Info, bool)

UserFrom returns the value of the user key on the ctx

func WithInfo

func WithInfo(parent context.Context, info *Info) context.Context

func WithUser

func WithUser(parent context.Context, user user.Info) context.Context

WithUser returns a copy of parent in which the user value is set

func WithValue

func WithValue(parent context.Context, key interface{}, val interface{}) context.Context

WithValue returns a copy of parent in which the value associated with key is val.

Types

type Info

type Info struct {
	// IsResourceRequest indicates whether or not the request is for an API resource or subresource
	IsResourceRequest bool
	// Path is the URL path of the request
	Path string
	// Verb is the kube verb associated with the request for API requests, not the http verb.  This includes things like list and watch.
	// for non-resource requests, this is the lowercase http verb
	Verb string

	APIPrefix  string
	APIGroup   string
	APIVersion string
	// Resource is the name of the resource being requested.  This is not the kind.  For example: pods
	Resource string
	// Subresource is the name of the subresource being requested.  This is a different resource, scoped to the parent resource, but it may have a different kind.
	// For instance, /pods has the resource "pods" and the kind "Pod", while /pods/foo/status has the resource "pods", the sub resource "status", and the kind "Pod"
	// (because status operates on pods). The binding resource for a pod though may be /pods/foo/binding, which has resource "pods", subresource "binding", and kind "Binding".
	Subresource string
	// Name is empty for some verbs, but if the request directly indicates a name (not in body content) then this field is filled in.
	Name string
}

func InfoFrom

func InfoFrom(ctx context.Context) (*Info, bool)

type InfoFactory

type InfoFactory struct {
	APIPrefixes sets.Set[string]
}

func (*InfoFactory) NewRequestInfo

func (i *InfoFactory) NewRequestInfo(req *http.Request) (*Info, error)

type Resolver

type Resolver interface {
	NewRequestInfo(req *http.Request) (*Info, error)
}

Jump to

Keyboard shortcuts

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