Documentation ¶
Overview ¶
Package context implements a simple request-aware HTTP context designed to be used via middleware layer to share polymorfic data.
context is not thread-safe by default.
Index ¶
- Constants
- func Clear(req *http.Request)
- func Delete(req *http.Request, key interface{})
- func Get(req *http.Request, key interface{}) interface{}
- func GetAll(req *http.Request) map[interface{}]interface{}
- func GetError(req *http.Request, key interface{}) error
- func GetOk(req *http.Request, key interface{}) (val interface{}, ok bool)
- func GetString(req *http.Request, key interface{}) string
- func Set(req *http.Request, key interface{}, value interface{})
- type ReadCloser
Constants ¶
const Version = "0.1.0"
Version stores the current package semantic version.
Variables ¶
This section is empty.
Functions ¶
func GetAll ¶
GetAll returns all stored context values for a request. Will always return a valid map. Returns an empty map for requests context data previously set.
func GetError ¶
GetError gets a error context value from req. Returns nil if key not found in the request context, or the value does not evaluate to a error.
func GetOk ¶
GetOk gets a context value from req. Returns (nil, false) if key not found in the request context.
Types ¶
type ReadCloser ¶
type ReadCloser interface { io.ReadCloser Context() map[interface{}]interface{} }
ReadCloser augments the io.ReadCloser interface with a Context() method.