gourdctx

package
v1.0.1-0...-8e9dff6 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2018 License: MIT Imports: 5 Imported by: 2

README

Context

Context provides a simple wrapper of github.com/gorilla/context.

It is based on gorilla.go in on a The Go Blog post, Go Concurrency Pattern.

Slight improvement are done to make it better by default.

Licence

Besides wrapper, which is written Sameer Ajmani, this software is licenced with MIT Licence. You may find a copy of the licence in the LICENCE file in the root folder.

Documentation

Index

Constants

View Source
const IDHeaderKey = "X-Request-ID"

IDHeaderKey is the string key used to store context ID in HTTP header

Variables

This section is empty.

Functions

func ClearGorilla

func ClearGorilla(inner endpoint.Endpoint) endpoint.Endpoint

ClearGorilla implements go-kit endpoint.Middleware that removes all values stored for a given request. Works like ClearHandler provided by gorilla

func GetID

func GetID(ctx context.Context) string

GetID get the string ID from request

func GetRequestID

func GetRequestID(r *http.Request) string

GetRequestID get string id from http request

func HTTPRequest

func HTTPRequest(ctx context.Context) *http.Request

HTTPRequest returns the *http.Request associated with ctx using NewContext, if any.

func New

func New(r *http.Request) context.Context

New returns a context.Context that also return gorilla/context values

func NewEmpty

func NewEmpty() context.Context

NewEmpty returns a basic implementation of context.Context that has no value at all

func UseGorilla

func UseGorilla(parent context.Context, r *http.Request) context.Context

UseGorilla implements go-kit http transport RequestFunc

func UseID

func UseID(parent context.Context, r *http.Request) context.Context

UseID add a string id to http request header and context

func WithGorilla

func WithGorilla(parent context.Context, r *http.Request) context.Context

WithGorilla wraps a given context.Context with our wrapper context. It also runs WithHTTPRequest inside.

func WithHTTPRequest

func WithHTTPRequest(parent context.Context, r *http.Request) context.Context

WithHTTPRequest adds the current HTTP Request to context.Context

func WithID

func WithID(parent context.Context, id string) context.Context

WithID add a string ID to the context (for session tracking)

Types

This section is empty.

Jump to

Keyboard shortcuts

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