linex

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: May 10, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewNode

func NewNode() *node

Types

type Context

type Context struct {
	Writer     http.ResponseWriter // writer
	Req        *http.Request       // request
	Path       string              // request.url.path
	Method     string              // method
	Params     map[string]string   // uri参数
	StatusCode int                 // response status code
	// contains filtered or unexported fields
}

func NewContext

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

新建 context 方法

func (*Context) Data

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

返回 二进制数据

func (*Context) HTML

func (c *Context) HTML(code int, html string)

返回 HTML 模板

func (*Context) JSON

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

返回 JSON

func (*Context) Next

func (c *Context) Next()

func (*Context) Param

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

获取 URI 中的参数

func (*Context) PostForm

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

查询POST FORM中的参数

func (*Context) Query

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

查询get中的参数

func (*Context) SetHeader

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

设置头信息

func (*Context) Status

func (c *Context) Status(code int)

响应状态码

func (*Context) String

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

返回string

type Engine

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

func Default

func Default() *Engine

新建一个使用默认中间件的 linex server服务

func New

func New() *Engine

新建一个无中间件的 linex server服务

func (*Engine) Run

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

server 运行方法

func (*Engine) ServeHTTP

func (e *Engine) ServeHTTP(w http.ResponseWriter, req *http.Request)

实现接口

type H

type H map[string]interface{}

别名 方便转换json

type HandlerFunc

type HandlerFunc func(*Context)

别名

func Logger

func Logger() HandlerFunc

func Recovery

func Recovery() HandlerFunc

type RouterGroup

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

func (*RouterGroup) GET

func (group *RouterGroup) GET(pattern string, handler HandlerFunc)

GET 方法

func (*RouterGroup) Group

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

func (*RouterGroup) POST

func (group *RouterGroup) POST(pattern string, handler HandlerFunc)

POST 方法

func (*RouterGroup) Use

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

添加中间件

Jump to

Keyboard shortcuts

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