muxContext

package
v0.1.11 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2020 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package muxContext defines a simple context that can be used with HTTP requests to easily store multiple pieces of information within the same http.Request context.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EMuxContext

type EMuxContext struct {
	// contains filtered or unexported fields
}

EMuxContext is a simple map used to organize multiple pieces of information within one http.Request context. It has been written to be concurrency safe under read/write operations using the methods provided.

func Create

func Create() *EMuxContext

Create returns a pointer to an empty EMuxContext.

func IsolateCtx

func IsolateCtx(r *http.Request) (*EMuxContext, error)

IsolateCtx returns a pointer to the EMuxContext which is stored within the context of the given request, and any errors associated with the operation.

If the context does not exist, entityErrors.MuxCtxNotFound is returned. If the context cannot be parsed, entityErrors.MuxCtxCorrupt is returned.

func (*EMuxContext) EmbedCtx

func (emc *EMuxContext) EmbedCtx(r *http.Request, parentCtx context.Context) *http.Request

EmbedCtx returns the given request, with its context modified to include the given emc.

func (*EMuxContext) Retrieve

func (emc *EMuxContext) Retrieve(key string) interface{}

Get retrieves the payload stored under the given keyStr in the EMucContext *emc.

func (*EMuxContext) Set

func (emc *EMuxContext) Set(key string, payload interface{}) error

Set stores the given payload in the EMuxContext *emc under the given keyStr.

Jump to

Keyboard shortcuts

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