zero

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2020 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GET     = "GET"
	HEAD    = "HEAD"
	POST    = "POST"
	PUT     = "PUT"
	PATCH   = "PATCH" // RFC 5789
	DELETE  = "DELETE"
	CONNECT = "CONNECT"
	OPTIONS = "OPTIONS"
	TRACE   = "TRACE"
)

支持的请求方式

Variables

View Source
var (
	NotFoundError = errors.New("404 NOT FOUND")
)

Functions

This section is empty.

Types

type Context

type Context struct {
	// request info
	Req        *http.Request     // 请求
	Path       string            //路径
	Method     string            // 请求方式
	Params     map[string]string // 路径参数
	StatusCode int
	// response info
	Res http.ResponseWriter //返回
	// contains filtered or unexported fields
}

func (*Context) Data

func (c *Context) Data(code int, data []byte)

func (*Context) Fail

func (c *Context) Fail(code int, err string)

Fail 错误信息

func (*Context) Get

func (c *Context) Get(key string) (value interface{}, ok bool)

Get 返回与键关联的接口值

func (*Context) GetBool

func (c *Context) GetBool(key string) (b bool, ok bool)

GetBool 返回与键关联的布尔值

func (*Context) GetDuration

func (c *Context) GetDuration(key string) (d time.Duration, ok bool)

GetDuration 返回与键关联的时间间隔值.

func (*Context) GetFloat64

func (c *Context) GetFloat64(key string) (f64 float64, ok bool)

GetFloat64 返回与值关联的双精度浮点数

func (*Context) GetInt

func (c *Context) GetInt(key string) (i int, ok bool)

GetInt 返回与值关联的整型值

func (*Context) GetInt64

func (c *Context) GetInt64(key string) (i64 int64, ok bool)

GetInt64 返回与值关联的64位整型值

func (*Context) GetString

func (c *Context) GetString(key string) (s string, ok bool)

GetString 返回与键关联的字符串

func (*Context) GetStringMap

func (c *Context) GetStringMap(key string) (sm map[string]interface{}, ok bool)

GetStringMap 返回与键关联的值作为接口映射.

func (*Context) GetStringMapString

func (c *Context) GetStringMapString(key string) (sms map[string]string, ok bool)

GetStringMapString 返回与键关联的值作为字符串映射.

func (*Context) GetStringMapStringSlice

func (c *Context) GetStringMapStringSlice(key string) (smss map[string][]string, ok bool)

GetStringMapStringSlice 返回与键关联的值,作为映射到字符串切片的映射.

func (*Context) GetStringSlice

func (c *Context) GetStringSlice(key string) (ss []string, ok bool)

GetStringSlice 返回与键关联的切片字符串值.

func (*Context) GetTime

func (c *Context) GetTime(key string) (t time.Time, ok bool)

GetTime 返回与键关联的时间值

func (*Context) GetUint

func (c *Context) GetUint(key string) (ui uint, ok bool)

GetUint 返回与值关联的整型值

func (*Context) GetUint64

func (c *Context) GetUint64(key string) (ui64 uint64, ok bool)

GetUint64 返回与值关联的无符号64位整型值

func (*Context) HTML

func (c *Context) HTML(code int, name string, data interface{})

func (*Context) JSON

func (c *Context) JSON(code int, obj interface{})

func (*Context) MustGet

func (c *Context) MustGet(key string) interface{}

MustGet 返回与键关联的接口值,如果不存在则报错

func (*Context) Next

func (c *Context) Next()

Next 执行下一个中间件

func (*Context) Param

func (c *Context) Param(key string) string

func (*Context) PostForm

func (c *Context) PostForm(key string) string

func (*Context) Query

func (c *Context) Query(key string)

func (*Context) Set

func (c *Context) Set(key string, value interface{})

***************************

  • 上下文数据存储 ***************************

Set 设置键和值

func (*Context) SetHeader

func (c *Context) SetHeader(key string, value string)

func (*Context) Status

func (c *Context) Status(statusCode int)

func (*Context) String

func (c *Context) String(code int, format string, values ...interface{})

type Engine

type Engine struct {
	*RouterGroup
	// contains filtered or unexported fields
}

Engine implement the interface of ServeHTTP

func Default

func Default() *Engine

func New

func New() *Engine

func (*Engine) DELETE

func (e *Engine) DELETE(pattern string, handlers ...HandlerFunc)

func (*Engine) GET

func (e *Engine) GET(pattern string, handlers ...HandlerFunc)

func (*Engine) HEAD

func (e *Engine) HEAD(pattern string, handlers ...HandlerFunc)

func (*Engine) LoadHTMLGlob

func (e *Engine) LoadHTMLGlob(pattern string)

func (*Engine) POST

func (e *Engine) POST(pattern string, handlers ...HandlerFunc)

func (*Engine) PUT

func (e *Engine) PUT(pattern string, handlers ...HandlerFunc)

func (*Engine) Run

func (e *Engine) Run(addr string) (err error)

Run 启动http服务器

func (*Engine) ServeHTTP

func (e *Engine) ServeHTTP(writer http.ResponseWriter, request *http.Request)

func (*Engine) SetFuncMap

func (e *Engine) SetFuncMap(funcMap template.FuncMap)

type HandlerFunc

type HandlerFunc func(ctx *Context)

HandlerFunc defines the request handler used by gee

func LoggerDefault

func LoggerDefault() HandlerFunc

func Recovery

func Recovery() HandlerFunc

type IRouter

type IRouter interface {
	GET(pattern string, handlers ...HandlerFunc)
	POST(pattern string, handlers ...HandlerFunc)
	PUT(pattern string, handlers ...HandlerFunc)
	DELETE(pattern string, handlers ...HandlerFunc)
	HEAD(pattern string, handlers ...HandlerFunc)
}

type RouterGroup

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

分组路由

func (*RouterGroup) DELETE

func (rg *RouterGroup) DELETE(pattern string, handlers ...HandlerFunc)

DELETE 添加DELETE路由

func (*RouterGroup) GET

func (rg *RouterGroup) GET(pattern string, handlers ...HandlerFunc)

GET 添加GET路由

func (*RouterGroup) Group

func (rg *RouterGroup) Group(prefix string) *RouterGroup

func (*RouterGroup) HEAD

func (rg *RouterGroup) HEAD(pattern string, handlers ...HandlerFunc)

HEAD 添加HEAD路由

func (*RouterGroup) POST

func (rg *RouterGroup) POST(pattern string, handlers ...HandlerFunc)

POST 添加POST路由

func (*RouterGroup) PUT

func (rg *RouterGroup) PUT(pattern string, handlers ...HandlerFunc)

PUT 添加PUT路由

func (*RouterGroup) Static

func (rg *RouterGroup) Static(relativePath string, root string)

serve static files

func (*RouterGroup) Use

func (rg *RouterGroup) Use(middlewares ...HandlerFunc)

type Z

type Z map[string]interface{}

Jump to

Keyboard shortcuts

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