server

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddAfterHandler

func AddAfterHandler(name string, action EzAction)

func AddBeforeHandler

func AddBeforeHandler(name string, action EzAction)

func AddFinisher

func AddFinisher(name string, action EzAction)

func AddPreparer

func AddPreparer(name string, action EzAction)

func Dispatch

func Dispatch(operation *Operation)

func PublicHandle

func PublicHandle(handler *EzHandler, operation *Operation)

func Run

func Run()

Types

type EzAction

type EzAction func(operation *Operation)

type EzFunc

type EzFunc func(operation *Operation)

type EzHandler

type EzHandler struct {
	Matcher    string
	Router     *Router
	Action     *EzAction
	Public     map[string]*PublicData //公开数据
	ActionSort []string
	StatusCode int //允许中断
	Actions    map[string]map[string]*EzAction
	CurAction  *EzAction
	IsStop     bool
}

func Do

func Do(router *Router, action EzAction) *EzHandler

func NewEzHandler

func NewEzHandler(router *Router, action *EzAction) *EzHandler

func (*EzHandler) Add

func (this *EzHandler) Add(weight int, name string, action EzAction) *EzHandler

func (*EzHandler) Get

func (this *EzHandler) Get(dataName string) interface{}

func (*EzHandler) Run

func (this *EzHandler) Run(operation *Operation)

func (*EzHandler) SAdd added in v1.0.1

func (this *EzHandler) SAdd(weight int, name string, action EzAction) *EzHandler

仅供框架使用,用于一些weight小于10或者大于99的方法的创建

func (*EzHandler) Set

func (this *EzHandler) Set(dataName string, data interface{})

type Input

type Input struct {
	Request *http.Request
	Url     string
	UrlData map[string]string
	Json    []byte
	Form    url.Values
}

func GetInputFromRequest

func GetInputFromRequest(req *http.Request) *Input

func NewInput

func NewInput() *Input

func (*Input) Get

func (this *Input) Get(key string) *InputAnyThing

func (*Input) GetFromGetPost

func (this *Input) GetFromGetPost(key string) *InputAnyThing

func (*Input) GetFromJson

func (this *Input) GetFromJson(key string) *InputAnyThing

func (*Input) GetFromUrl

func (this *Input) GetFromUrl(key string) *InputAnyThing

type InputAnyThing

type InputAnyThing struct {
	Receive interface{}
}

func NewInputAnyThing

func NewInputAnyThing(v interface{}) *InputAnyThing

func (*InputAnyThing) IsBool

func (this *InputAnyThing) IsBool(def ...bool) bool

func (*InputAnyThing) IsFloat32

func (this *InputAnyThing) IsFloat32(def ...float32) float32

func (*InputAnyThing) IsFloat64

func (this *InputAnyThing) IsFloat64(def ...float64) float64

func (*InputAnyThing) IsInt

func (this *InputAnyThing) IsInt(def ...int) int

func (*InputAnyThing) IsInt16

func (this *InputAnyThing) IsInt16(def ...int16) int16

func (*InputAnyThing) IsInt32

func (this *InputAnyThing) IsInt32(def ...int32) int32

func (*InputAnyThing) IsInt64

func (this *InputAnyThing) IsInt64(def ...int64) int64

func (*InputAnyThing) IsInt8

func (this *InputAnyThing) IsInt8(def ...int8) int8

func (*InputAnyThing) IsMap

func (this *InputAnyThing) IsMap() map[string]interface{}

func (*InputAnyThing) IsString

func (this *InputAnyThing) IsString(def ...string) string

func (*InputAnyThing) IsUint

func (this *InputAnyThing) IsUint(def ...uint) uint

func (*InputAnyThing) IsUint16

func (this *InputAnyThing) IsUint16(def ...uint16) uint16

func (*InputAnyThing) IsUint32

func (this *InputAnyThing) IsUint32(def ...uint32) uint32

func (*InputAnyThing) IsUint64

func (this *InputAnyThing) IsUint64(def ...uint64) uint64

func (*InputAnyThing) IsUint8

func (this *InputAnyThing) IsUint8(def ...uint8) uint8

type JsonOut

type JsonOut struct {
	Code    int         `json:"code"`
	Message string      `json:"message"`
	Data    interface{} `json:"data"`
}

func NewJsonOut

func NewJsonOut(p ...interface{}) *JsonOut

type Operation

type Operation struct {

	//链路key
	ChainKey string

	//处理数据输入
	Input *Input
	//处理数据输出
	Output *Output
	//作为协作模式的数据共享中心
	//Coordination Coordination
	Handler *EzHandler
	//操作计时器
	Timer *core.Timer
	//Logger
	Logger *core.Logger

	//是否中止
	IsStop bool
}

func GetOperationFromContext

func GetOperationFromContext(ctx context.Context) *Operation

func NewOperation

func NewOperation(resp http.ResponseWriter, req *http.Request) *Operation

func (*Operation) CreateContext

func (this *Operation) CreateContext() context.Context

func (*Operation) FillJson

func (this *Operation) FillJson(model interface{}) error

func (*Operation) Get

func (this *Operation) Get(key string) *InputAnyThing

func (*Operation) GetHeader

func (this *Operation) GetHeader() http.Header

func (*Operation) GetPublic

func (this *Operation) GetPublic(dataName string) interface{}

func (*Operation) Html

func (this *Operation) Html(data string)

func (*Operation) JsonOut

func (this *Operation) JsonOut(data interface{})

func (*Operation) SetHeader

func (this *Operation) SetHeader(key string, value string)

func (*Operation) SetPublic

func (this *Operation) SetPublic(dataName string, data interface{})

func (*Operation) Stop

func (this *Operation) Stop()

func (*Operation) StopHandle

func (this *Operation) StopHandle()

Handler

type Output

type Output struct {
	Response http.ResponseWriter
	Writer   *bytes.Buffer
	Body     []byte
}

func (*Output) Byte

func (this *Output) Byte(data []byte)

func (*Output) Html

func (this *Output) Html(data string)

func (*Output) Json

func (this *Output) Json(data interface{})

type PublicData

type PublicData struct {
	V     interface{}
	Read  int
	Write int
	Chan  chan int
}

type RouteHub

type RouteHub struct {
	//直接匹配的路由
	DirectRouter map[string]*EzHandler
	//正则匹配的路由
	RegxRouter map[string]*EzHandler
	//全局前置中间件
	Preparer map[string]*EzAction
	//全局后置中间件
	Finisher map[string]*EzAction
	//Handler前置操作,区别于前置操作,这时已经可以获取到route等信息了
	BeforeHandler map[string]*EzAction
	//Handler后置操作
	AfterHandler map[string]*EzAction
}

func GetRouteHub added in v1.0.2

func GetRouteHub() *RouteHub

func NewRouteHub

func NewRouteHub() *RouteHub

func (*RouteHub) AddDirectRoute

func (this *RouteHub) AddDirectRoute(router *Router, action *EzAction) *EzHandler

func (*RouteHub) AddRegxRoute

func (this *RouteHub) AddRegxRoute(router *Router, action *EzAction) *EzHandler

type Router

type Router struct {
	Url    string
	Group  string
	Prefix string
	Suffix string
}

type ServerHandler

type ServerHandler struct {
	http.Handler
}

func NewServerHandler

func NewServerHandler() *ServerHandler

func (*ServerHandler) ServeHTTP

func (this *ServerHandler) ServeHTTP(resp http.ResponseWriter, req *http.Request)

Jump to

Keyboard shortcuts

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