neo

package
v0.0.0-...-06ac355 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Context

type Context struct {
	// 原始的请求和响应对象
	Writer http.ResponseWriter
	Req    *http.Request

	// 当此请求方式
	Method string
	// 当此请求地址
	URL string
}

func NewContext

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

func (*Context) HTML

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

HTML 返回HTML格式数据

func (*Context) JSON

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

JSON 返回JSON格式树 JSON格式数据特殊点,需要给它先序列化

func (*Context) PostForm

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

PostForm 获取请求体数据 TODO 注意,根据用户传过来的数据格式的不同,获取数据的方式也是不同的。具体可以参考Gin

func (*Context) Query

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

Query 获取查询参数

func (*Context) SetHeader

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

SetHeader 设置响应头

func (*Context) Status

func (c *Context) Status(code int)

Status 设置响应状态码

func (*Context) String

func (c *Context) String(code int, template string, value ...string)

String 返回纯文本格式数据

type Engine

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

func New

func New() *Engine

func (*Engine) DELETE

func (e *Engine) DELETE(pattern string, handlerFunc HandlerFunc)

func (*Engine) GET

func (e *Engine) GET(pattern string, handlerFunc HandlerFunc)

GET 外部衍生API,提供给用户使用

func (*Engine) POST

func (e *Engine) POST(pattern string, handlerFunc HandlerFunc)

func (*Engine) PUT

func (e *Engine) PUT(pattern string, handlerFunc HandlerFunc)

func (*Engine) Run

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

Run 手动启动服务,控制力强

func (*Engine) ServeHTTP

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

对外对接用户,对内对接Web框架

type HandlerFunc

type HandlerFunc func(ctx *Context)

HandlerFunc 视图函数签名

Jump to

Keyboard shortcuts

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