Documentation ¶
Overview ¶
Package http
Package http ¶
Package http ¶
Package http ¶
Package http ¶
Package http ¶
Package http ¶
Package http ¶
Package http ¶
Package http
Index ¶
- Constants
- func ModuleName() string
- type Address
- type Context
- func (c *Context) BeforeResponse()
- func (c *Context) Response(t string, s int, data interface{})
- func (c *Context) ResponseAny(data interface{})
- func (c *Context) ResponseBad(t string, data interface{})
- func (c *Context) ResponseFile(s int, f string)
- func (c *Context) ResponseGood(t string, data interface{})
- func (c *Context) ResponseHtml(s int, f string)
- func (c *Context) ResponseREST(s int, data interface{})
- func (c *Context) ResponseStr(s int, data string)
- type Router
- type RouterGroup
- type Server
- func (s *Server) Group(path string, wrap ...WrapperFunc) *RouterGroup
- func (s *Server) Init()
- func (s *Server) Listen() error
- func (s *Server) ListenSmooth()
- func (s *Server) RegMiddle(mds ...Wrapper)
- func (s *Server) RegSignals(sigs ...os.Signal)
- func (s *Server) Route(method, uri string, wrap ...WrapperFunc)
- func (s *Server) Run()
- type Wrapper
- type WrapperFunc
Constants ¶
View Source
const ( ErrEngineEmpty = "engine is not init" ErrServerClosed = "server is closed" )
View Source
const ( GET = "GET" POST = "POST" PUT = "PUT" DELETE = "DELETE" PATCH = "PATCH" OPTION = "OPTION" )
View Source
const ( REST = "REST" HTML = "HTML" STRING = "STRING" FILE = "FILE" )
Variables ¶
This section is empty.
Functions ¶
func ModuleName ¶
func ModuleName() string
Types ¶
type Context ¶
func (*Context) ResponseAny ¶
func (c *Context) ResponseAny(data interface{})
ResponseAny 不做类型推断返回stream
func (*Context) ResponseBad ¶
ResponseBad 错误响应500
func (*Context) ResponseFile ¶
ResponseFile alias of response with type file
func (*Context) ResponseGood ¶
ResponseGood 200响应
func (*Context) ResponseHtml ¶
ResponseHtml alias of response with type html
func (*Context) ResponseREST ¶
ResponseREST alias of response with type rest
func (*Context) ResponseStr ¶
ResponseStr alias of response with type string
type RouterGroup ¶
type RouterGroup struct {
*gin.RouterGroup
}
type Server ¶
type Server struct { EnableLog bool // 使用内置的日志打印 默认输出到控制台 Logger log.LoggerInterface // 使用的日志记录器 默认为内置日志 Debug bool // 开启gin的debug RegSignal []os.Signal // 监听系统信号量 Address Address // 监听地址 Headers map[string]string // 自定义的Headers Copyright string // 版权所有 会以header: Copyright: xx的方式返回在响应中 MaxBodySize int // 最大请求体限制 默认1<<20 bytes ReadTimeout int // 继承http.Server WriteTimeout int // 继承http.Server IdleTimeout int // 继承http.Server // todo tls PProf bool // 是否开启pprof 路径为"debug/pprof" // contains filtered or unexported fields }
func (*Server) Group ¶
func (s *Server) Group(path string, wrap ...WrapperFunc) *RouterGroup
Group 路由分组
func (*Server) ListenSmooth ¶
func (s *Server) ListenSmooth()
ListenSmooth 平滑关闭 在注册监听signal的时候生效 默认注册CTRL+C
func (*Server) RegSignals ¶
RegSignals 信号注册 默认为空时注册interrupt可能导致其他loop无法退出 所以仅在debug模式下注册此信号
func (*Server) Route ¶
func (s *Server) Route(method, uri string, wrap ...WrapperFunc)
type Wrapper ¶
type Wrapper struct { Name string WrapperFunc WrapperFunc }
type WrapperFunc ¶
type WrapperFunc func(c *Context)
func MiddleWareCors ¶ added in v1.1.2
func MiddleWareCors() WrapperFunc
MiddleWareCors 默认的cors 允许所有跨域
Click to show internal directories.
Click to hide internal directories.