context

package
v0.0.0-...-174ac3b Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2022 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Context

type Context struct {
	// named parameters that are passed in via RESTful URL Parameters
	Params Params

	// named attributes that persist for the lifetime of the request
	Values Values
	// contains filtered or unexported fields
}

Context stores data for the duration of the http.Request

func Get

func Get(r *http.Request) *Context

Retruns the Context associated with the http.Request.

func (*Context) Request

func (c *Context) Request() *http.Request

Retruns the parent http.Request to which the context is bound.

type Params

type Params map[string]string

Params maps a string key to a list of values.

func (Params) Del

func (p Params) Del(key string)

Del deletes the values associated with key.

func (Params) Get

func (p Params) Get(key string) string

Get gets the first value associated with the given key. If there are no values associated with the key, Get returns the empty string.

func (Params) Set

func (p Params) Set(key, value string)

Set sets the key to value. It replaces any existing values.

type Values

type Values map[interface{}]interface{}

Values maps a string key to a list of values.

func (Values) Del

func (v Values) Del(key interface{})

Del deletes the values associated with key.

func (Values) Get

func (v Values) Get(key interface{}) interface{}

Get gets the value associated with the given key. If there are no values associated with the key, Get returns nil.

func (Values) GetStr

func (v Values) GetStr(key interface{}) interface{}

GetStr gets the value associated with the given key in string format. If there are no values associated with the key, Get returns an empty string.

func (Values) Set

func (v Values) Set(key, value interface{})

Set sets the key to value. It replaces any existing values.

Jump to

Keyboard shortcuts

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