ctx

package
v0.0.0-...-a12e6e1 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2021 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Std mod = iota
	EPoll
)

Variables

This section is empty.

Functions

func DisableLog

func DisableLog()

func Print

func Print()

func Register

func Register(method, path string, handlerFuncs ...handlerFunc)

func SetDefaultHandler

func SetDefaultHandler(status int16, handler handlerFunc)

func WapEPoll

func WapEPoll(buf []byte) []byte

func WrapStd

func WrapStd(conn net.Conn, typ string)

Types

type AbortI

type AbortI interface {
	// GetMessage return the abort response bytes
	GetAbortMessage() []byte
	NewAbort(status int16, message interface{}) *abortContext
}

type ControlStrategy

type ControlStrategy interface {
	Do() bool
}

type GroupI

type GroupI interface {
	Register(method, path string, handlerFuncs ...handlerFunc)
	Group(path string, handlerFuncs ...handlerFunc) GroupI
}

func Group

func Group(path string, handlerFuncs ...handlerFunc) GroupI

type ReqCxtI

type ReqCxtI interface {
	RspCtxI
	AbortI
	StrategyI

	// Abort response with status
	// setAbort can make the current flow stop.
	// set the stop time & set the finished flag true
	Abort(status int16, message interface{})
	// Set into sync.map
	Set(key string, val interface{})
	// Get from sync.map
	Get(key string) interface{}
	// Push calling push when execute a HandlerFunc and push the next Handler
	// to execute or jump to anther HandlerFunc to deal with the request.
	Next(handlerFunc handlerFunc)

	GetQuery(key, dft string) string
	// ParseBody turn the body bytes to dst
	ParseBody(dst interface{}) error

	// RegisterStrategy register the customized strategy
	RegisterStrategy(strategy *StrategyContext)

	SaveLocalFile(dst string)
}

type RequestContext

type RequestContext struct {
	*StrategyContext
	// contains filtered or unexported fields
}

RequestContext contains all the engine when a req has triggered

func (*RequestContext) Abort

func (rc *RequestContext) Abort(status int16, message interface{})

func (*RequestContext) Get

func (rc *RequestContext) Get(key string) interface{}

func (RequestContext) GetAbortMessage

func (ac RequestContext) GetAbortMessage() []byte

func (*RequestContext) GetFile

func (rc *RequestContext) GetFile() multipart.File

func (*RequestContext) GetFileName

func (rc *RequestContext) GetFileName() string

func (*RequestContext) GetMethod

func (rc *RequestContext) GetMethod() string

func (*RequestContext) GetPath

func (rc *RequestContext) GetPath() string

func (*RequestContext) GetQuery

func (rc *RequestContext) GetQuery(key, dft string) string

func (RequestContext) JSON

func (rsp RequestContext) JSON(status int16, response interface{})

func (RequestContext) NewAbort

func (ac RequestContext) NewAbort(status int16, message interface{}) *abortContext

func (*RequestContext) Next

func (rc *RequestContext) Next(handlerFunc handlerFunc)

func (*RequestContext) ParseBody

func (rc *RequestContext) ParseBody(dst interface{}) error

func (*RequestContext) RegisterStrategy

func (rc *RequestContext) RegisterStrategy(strategy *StrategyContext)

func (*RequestContext) SaveLocalFile

func (rc *RequestContext) SaveLocalFile(dst string)

func (*RequestContext) Set

func (rc *RequestContext) Set(key string, val interface{})

func (RequestContext) SetStopTime

func (rsp RequestContext) SetStopTime(t time.Time)

type RspCtxI

type RspCtxI interface {
	// JSON response
	JSON(status int16, response interface{})
}

type StrategyContext

type StrategyContext struct {
	// time to live, stack execute profundity.
	Ttl int32

	// set Async identification to inform program to execute
	// the method by asynchronous. TimeOut option is an async true
	Timeout time.Duration

	Async bool

	// fusing resistor to protect the third part dependency.
	// or other purpose that you made.
	Fusing ControlStrategy

	// for security reason, attack recognition or any other optional
	// functions can be made && check here.
	Security ControlStrategy
	// contains filtered or unexported fields
}

strategy is under developing now, it functions will enhanced later

func (*StrategyContext) SetTTL

func (s *StrategyContext) SetTTL(t int32)

SetTTL the stack is inc 1 to the t set

func (*StrategyContext) SetTimeOut

func (s *StrategyContext) SetTimeOut(t time.Duration)

type StrategyI

type StrategyI interface {
	SetTimeOut(t time.Duration)
	SetTTL(t int32)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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