vix

package module
v0.0.0-...-09b0d49 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	START = "*"
	ROD   = "/"
)
View Source
const (
	SWEAT  = ':'
	SYMBOL = '@'
)

Variables

This section is empty.

Functions

func DisallowUnknownFields

func DisallowUnknownFields()

func UseNumber

func UseNumber()

Types

type Context

type Context struct {
	Req       *http.Request
	Resp      http.ResponseWriter
	PathParam map[string]string
}

func (*Context) BindJSON

func (c *Context) BindJSON(target any) error

BindJSON 全局JSON解析器 可以通过UseNumber和DisallowUnknownFields方法来控制全局的json解析的力度

func (*Context) BindJSONbyOpt

func (c *Context) BindJSONbyOpt(target any, numberUse bool, disallow bool) error

BindJSONbyOpt 控制单个json解析的力度 numberUse:是否开启number模式,开启后以Number作为数字类型,默认是float64 disallow:是否开启json检测,当json中有结构体未定义的对象时报错

type HTTPServer

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

func NewVIX

func NewVIX() *HTTPServer

func (*HTTPServer) AddRouter

func (h *HTTPServer) AddRouter(method, path string, handleFunc HandleFunc)

func (*HTTPServer) CONNECT

func (h *HTTPServer) CONNECT(path string, handleFunc HandleFunc)

CONNECT Connect请求

func (*HTTPServer) DELETE

func (h *HTTPServer) DELETE(path string, handleFunc HandleFunc)

DELETE Delete请求

func (*HTTPServer) GET

func (h *HTTPServer) GET(path string, handleFunc HandleFunc)

GET Get请求

func (*HTTPServer) HEAD

func (h *HTTPServer) HEAD(path string, handleFunc HandleFunc)

HEAD Head请求

func (*HTTPServer) OPTIONS

func (h *HTTPServer) OPTIONS(path string, handleFunc HandleFunc)

OPTIONS Options请求

func (*HTTPServer) PATCH

func (h *HTTPServer) PATCH(path string, handleFunc HandleFunc)

PATCH Patch请求

func (*HTTPServer) POST

func (h *HTTPServer) POST(path string, handleFunc HandleFunc)

POST Post请求

func (*HTTPServer) PUT

func (h *HTTPServer) PUT(path string, handleFunc HandleFunc)

PUT Put请求

func (*HTTPServer) Run

func (h *HTTPServer) Run(addr string) error

func (*HTTPServer) ServeHTTP

func (h *HTTPServer) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP 处理HTTP请求的入口

func (*HTTPServer) TRACE

func (h *HTTPServer) TRACE(path string, handleFunc HandleFunc)

TRACE Trace请求

type HandleFunc

type HandleFunc func(ctx *Context)

HandleFunc 处理方法

type Server

type Server interface {
	http.Handler
	// Run 服务启动入口
	Run(addr string) error
	// AddRouter 添加路由信息
	AddRouter(method, path string, handleFunc HandleFunc)
}

Server 抽象的Server服务器

Jump to

Keyboard shortcuts

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