Documentation ¶
Index ¶
- Constants
- Variables
- func BytesToString(b []byte) string
- func CodeMessage(rerrCode int) string
- func StringToBytes(s string) []byte
- func ToUriPath(name string) string
- type Context
- func (c *Context) ContentType() string
- func (c *Context) ContentTypeSet(value string)
- func (c *Context) GetRemoteIP() string
- func (c *Context) Head(key string) string
- func (c *Context) HeadSet(key, value string)
- func (c *Context) Method() string
- func (c *Context) Next()
- func (c *Context) Query(key string) string
- func (c *Context) QueryValues() url.Values
- func (c *Context) Redirect(targetUrl string, code int)
- func (c *Context) RemoteAddr() string
- func (c *Context) Render(obj interface{}) (int, error)
- func (c *Context) RenderRerr(rerr *Rerror) (int, error)
- func (c *Context) RenderString(resp string) (int, error)
- func (c *Context) RequestURI() string
- func (c *Context) Stream(step func(w io.Writer) bool) error
- func (c *Context) UserAgent() string
- type Plugin
- type Plugins
- type Rerror
- type Router
- func (r *Router) AddPlugin(plugins ...Plugin)
- func (r *Router) Get(relativePath string, plugins ...Plugin)
- func (r *Router) Group(relativePath string, plugins ...Plugin) *Router
- func (r *Router) Options(relativePath string, plugins ...Plugin)
- func (r *Router) Post(relativePath string, plugins ...Plugin)
- type Server
- type SrvConfig
Constants ¶
View Source
const ( // 公用错误码 CodeUnknownError = -1 CodeWriteFailed = 104 CodeInvalidParameter = 299 CodeBadPacket = 400 CodeNotFound = 404 CodeInternalServerError = 500 CodeBadGateway = 502 )
Variables ¶
View Source
var ( // 公用错误 RerrUnknown = NewRerror(CodeUnknownError, CodeMessage(CodeUnknownError), "") RerrWriteFailed = NewRerror(CodeWriteFailed, CodeMessage(CodeWriteFailed), "") RerrInvalidParameter = NewRerror(CodeInvalidParameter, CodeMessage(CodeInvalidParameter), "") RerrBadPacket = NewRerror(CodeBadPacket, CodeMessage(CodeBadPacket), "") RerrNotFound = NewRerror(CodeNotFound, CodeMessage(CodeNotFound), "") RerrInternalServer = NewRerror(CodeInternalServerError, CodeMessage(CodeInternalServerError), "") RerrBadGateway = NewRerror(CodeBadGateway, CodeMessage(CodeBadGateway), "") )
Functions ¶
Types ¶
type Context ¶
type Context struct { // Request Request *http.Request // ResponseWriter ResponseWriter http.ResponseWriter // contains filtered or unexported fields }
Context
func (*Context) RenderRerr ¶
RenderRerr response rerror
func (*Context) RenderString ¶
Render response json
type Rerror ¶
type Rerror struct { // Code 错误状态码 Code int `json:"code"` // Message 错误信息 Message string `json:"message"` // Reason 错误原因 Reason string `json:"reason"` }
Rerror 发生错误时返回的错误信息 response error
func (*Rerror) MarshalRerror ¶
MarshalRerror 错误信息编码
func (*Rerror) UnmarshalRerror ¶
UnmarshalRerror 解析错误信息
type Router ¶
type Router struct { Plugins Plugins // contains filtered or unexported fields }
Router
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
cmd
|
|
create/tpl
Package main generated by go-bindata.
|
Package main generated by go-bindata. |
run/fsnotify
Package fsnotify implements file system notification.
|
Package fsnotify implements file system notification. |
Package httprouter is a trie based high performance HTTP request router.
|
Package httprouter is a trie based high performance HTTP request router. |
Click to show internal directories.
Click to hide internal directories.