simple

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewServer

func NewServer(cnf ServerConf) *server

Types

type Action

type Action func(ctx *Context)

func (Action) ServeHTTP

func (act Action) ServeHTTP(res http.ResponseWriter, req *http.Request)

ServeHTTP 服务

type BaseController

type BaseController struct {
}

BaseController 控制器基础实现

func (*BaseController) After

func (b *BaseController) After(ctx *Context) error

func (*BaseController) Before

func (b *BaseController) Before(ctx *Context) error

func (*BaseController) Ignore

func (b *BaseController) Ignore() (lst []string)

func (*BaseController) Prefix

func (b *BaseController) Prefix() string

func (*BaseController) Recover

func (b *BaseController) Recover(ctx *Context, err interface{})

type Context

type Context struct {
	context.Context
	// contains filtered or unexported fields
}

func (*Context) ActionName

func (ctx *Context) ActionName() string

func (*Context) ControllerName

func (ctx *Context) ControllerName() string

func (*Context) FFloat64

func (ctx *Context) FFloat64(key string, def float64) float64

FFloat64 获取Float64参数

func (*Context) FInt

func (ctx *Context) FInt(key string, def int) int

FInt 获取int参数

func (*Context) FString

func (ctx *Context) FString(key string, def string) string

FString 获取字符串类型

func (*Context) GFloat64

func (ctx *Context) GFloat64(key string, def float64) float64

GFloat64 获取Float64参数

func (*Context) GInt

func (ctx *Context) GInt(key string, def int) int

GInt 获取int参数

func (*Context) GString

func (ctx *Context) GString(key string, def string) string

GString 获取字符串类型

func (*Context) Json

func (ctx *Context) Json(data interface{})

func (*Context) Proxy

func (ctx *Context) Proxy(target *url.URL)

Proxy 代理转换 target ->来源于注册中心or配置好的地址

func (*Context) Req

func (ctx *Context) Req() *http.Request

Req 请求体

func (*Context) Res

func (ctx *Context) Res() http.ResponseWriter

Res 响应体

func (*Context) Set

func (ctx *Context) Set(key interface{}, val interface{})

func (*Context) Value

func (ctx *Context) Value(key interface{}) (val interface{})

type Controller

type Controller interface {
	//Before Action前置操作(可以做相关逻辑:如跨域等处理)
	Before(ctx *Context) error
	//After Action后置操作(可以做相关逻辑:如跨域等处理)
	After(ctx *Context) error
	//Prefix Action接口前缀(分组名)
	Prefix() string
	//Ignore 忽略的Action
	Ignore() []string
	//Recover 异常抓取操作
	Recover(ctx *Context, err interface{})
}

type ServerConf

type ServerConf struct {
	Boot           string
	Mode           ServerMode
	IgnorePathCase bool
	ControllerPath string
}

type ServerMode

type ServerMode string

ServerMode 服务启动模式

const (
	DEBUG   ServerMode = "debug"
	RELEASE ServerMode = "release"
)

Jump to

Keyboard shortcuts

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