Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Namespace = func(ctx Context) (string, error) { return "", nil }
Namespace is a overrideable function which returns the namespace associated with the given context.
Functions ¶
func WithDeadline ¶
func WithDeadline(parent Context, deadline time.Time) (Context, CancelFunc)
WithDeadline returns a copy of the parent context with the deadline adjusted to be no later than d. If the parent's deadline is already earlier than d, WithDeadline(parent, d) is semantically equivalent to parent. The returned context's Done channel is closed when the deadline expires, when the returned cancel function is called, or when the parent context's Done channel is closed, whichever happens first.
func WithTimeout ¶
func WithTimeout(parent Context, timeout time.Duration) (Context, CancelFunc)
WithTimeout returns WithDeadline(parent, time.Now().Add(timeout)).
Types ¶
type CancelFunc ¶
type CancelFunc func()
CancelFunc is a context cancel func, matching the "context".CancelFunc interface
type Context ¶
type Context interface { Deadline() (deadline time.Time, ok bool) Done() <-chan struct{} Err() error Value(key interface{}) interface{} }
Context has the same interface as "context" and "golang.org/x/net/context" to handle imports in all go version
func NewContext ¶
NewContext creates a new context associated with the request.
type Key ¶
type Key string
Key is a string type for context value key names
var ( ContextKeyNamepace Key = "namespace" ContextKeyRequestBody Key = "request.body" ContextKeyRequestVars Key = "request.vars" ContextKeyResponseWriter Key = "http.responsewriter" ContextKeyRequest Key = "request" ContextKeyResponseCode Key = "response.code" ContextKeyInitialized Key = "initialized" ContextKeyResponseBody Key = "response.body" ContextKeyEnvironment Key = "environment" )
Context key location definitions