ghttp

package
v0.0.0-...-e027c79 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2022 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var GMid = new(Middleware)

GMid 全局对象

Functions

func Wrap

func Wrap(handle HandlerFunc) gin.HandlerFunc

Wrap ...包装成gin handlerFunc

Types

type Context

type Context struct {
	*gin.Context
}

Context wrap gin.context

func (*Context) JSONSend

func (c *Context) JSONSend(data interface{})

JSONSend ...返回200 json

type Gin

type Gin struct {
	Engine *gin.Engine
}

Gin framework

func New

func New(e *gin.Engine) *Gin

New 实例化

func (*Gin) Any

func (g *Gin) Any(relativePath string, handlers ...HandlerFunc) gin.IRoutes

Any registers a route that matches all the HTTP methods. GET, POST, PUT, PATCH, HEAD, OPTIONS, DELETE, CONNECT, TRACE.

func (*Gin) DELETE

func (g *Gin) DELETE(path string, hs ...HandlerFunc) gin.IRoutes

DELETE is a shortcut for router.Handle("DELETE", path, handle).

func (*Gin) GET

func (g *Gin) GET(path string, hs ...HandlerFunc) gin.IRoutes

GET is a shortcut for router.Handle("GET", path, handle).

func (*Gin) HEAD

func (g *Gin) HEAD(path string, hs ...HandlerFunc) gin.IRoutes

HEAD is a shortcut for router.Handle("HEAD", path, handle).

func (*Gin) Handle

func (g *Gin) Handle(httpMethod, path string, hs ...HandlerFunc) gin.IRoutes

Handle ...

func (*Gin) MultipleHandle

func (g *Gin) MultipleHandle(path, receiveMethod string, hs ...HandlerFunc)

MultipleHandle ...多路操作

func (*Gin) OPTIONS

func (g *Gin) OPTIONS(path string, hs ...HandlerFunc) gin.IRoutes

OPTIONS is a shortcut for router.Handle("OPTIONS", path, handle).

func (*Gin) PATCH

func (g *Gin) PATCH(path string, hs ...HandlerFunc) gin.IRoutes

PATCH is a shortcut for router.Handle("PATCH", path, handle).

func (*Gin) POST

func (g *Gin) POST(path string, hs ...HandlerFunc) gin.IRoutes

POST is a shortcut for router.Handle("POST", path, handle).

func (*Gin) PUT

func (g *Gin) PUT(path string, hs ...HandlerFunc) gin.IRoutes

PUT is a shortcut for router.Handle("PUT", path, handle).

type HandlerFunc

type HandlerFunc func(c *Context) (err error)

HandlerFunc ...

func WrapGinHandler

func WrapGinHandler(handler gin.HandlerFunc) HandlerFunc

WrapGinHandler wrap gin handlerFunc to HandlerFunc

type Map

type Map map[string]interface{}

Map 封装通用字典对象

type Middleware

type Middleware struct{}

Middleware 中间件

func (*Middleware) Cors

func (m *Middleware) Cors() gin.HandlerFunc

Cors ...

func (*Middleware) JWT

func (m *Middleware) JWT(c *Context) (err error)

JWT ...JWT中间件

type ResponseData

type ResponseData struct {
	Code    int         `json:"code"`
	Message interface{} `json:"message"`
	Hints   interface{} `json:"hints,omitempty"`
	Data    interface{} `json:"data,omitempty"`

	sync.RWMutex
	Map `json:"extend,omitempty"`
}

ResponseData 请求返回结构体

func NewResponse

func NewResponse(httpCode int, msg ...interface{}) (p *ResponseData)

NewResponse 返回ResponseData

func (*ResponseData) AddValue

func (r *ResponseData) AddValue(k string, value interface{})

AddValue ...添加一个数据

func (*ResponseData) Error

func (r *ResponseData) Error() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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