ctx

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 24, 2018 License: MIT Imports: 4 Imported by: 7

README

CJToolkit Context System

Just a simple context system for background and user request.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BackgroundContext

type BackgroundContext interface {
	Set(name string, value interface{})
	Get(name string) interface{}
	Persist(name string, fn func() (interface{}, error)) interface{}
}

Background Context

func NewBackgroundContext

func NewBackgroundContext() BackgroundContext

type Context

type Context interface {
	Title() string
	SetTitle(title string)
	Data(name string) interface{}
	SetData(name string, value interface{})
	PersistData(name string, fn func() interface{}) interface{}
	Dep(name string) interface{}
	SetDep(name string, value interface{})
	PersistDep(name string, fn func() interface{}) interface{}
	Request() *http.Request
	ResponseWriter() http.ResponseWriter
}

For storing anything related to user request

func GetContext

func GetContext(req *http.Request) Context

func NewContext

func NewContext(res http.ResponseWriter, req *http.Request) (*http.Request, Context)

Jump to

Keyboard shortcuts

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