Documentation
¶
Index ¶
- Constants
- type APIInfo
- type Context
- type Handle
- type HttpTest
- type PrometheusList
- type RespMsg
- type ResponseWriter
- func (lrw *ResponseWriter) AbortWithStatus(code int)
- func (lrw *ResponseWriter) Size() int
- func (lrw *ResponseWriter) Status() int
- func (lrw *ResponseWriter) Write(data []byte) (n int, err error)
- func (lrw *ResponseWriter) WriteHeader(code int)
- func (lrw *ResponseWriter) WriteString(s string) (n int, err error)
- func (lrw *ResponseWriter) Written() bool
- type Router
- func (router *Router) AddRoute(method, path string, perm uint, conf interface{}, handlers ...Handle)
- func (router *Router) NotFound()
- func (router *Router) PutRouterList(rl *RouterList, conf interface{})
- func (router *Router) ServeHTTP(w http.ResponseWriter, req *http.Request)
- func (router *Router) SetupPrometheus()
- type RouterList
Constants ¶
View Source
const ( /* 1: 登陆认证失败 2:用户请求数据处理失败 3:服务端处理失败 */ StatusOK = 0 StatusInvalidSign = 1000 StatusLoginFailed = 1003 StatusAccessDenied = 1199 // 请求参数合法性验证 StatusNotLegalInput = 1201 // json请求校验失败 StatusBodyInvalid = 1204 StatusDataProcessingFailed = 3000 StatusSaveDataFailed = 3001 StatusNotFound = 3010 )
View Source
const ( TypeJson = "application/json; charset=UTF-8" TypePlain = "text/plain; charset=UTF-8" TypeHtml = "text/html; charset=UTF-8" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Context ¶
type Context struct {
Req *http.Request
Writer *ResponseWriter
Params httprouter.Params
Keys map[string]interface{}
Response interface{}
Begin time.Time
NoLog bool
OpLog *bytes.Buffer
Body *bytes.Buffer
BodyLen int64
BodyMap map[string]interface{}
ContextType string
Perm uint
}
Context http会话期间的session
type HttpTest ¶
func (HttpTest) HttpApiTest ¶
type PrometheusList ¶
type PrometheusList struct {
RequestsInFlight prometheus.Gauge
ConcurrencyLimitExceeded prometheus.Counter
RequestsTotal *prometheus.CounterVec
RequestsURLTotal *prometheus.CounterVec
}
type RespMsg ¶
type RespMsg struct {
Code int `json:"code"`
DataList interface{} `json:"dataList"`
TotalRecord int `json:"totalRecord"`
PageSize int `json:"pagesize"`
PageNo int `json:"pageno"`
Message string `json:"message"`
}
RespMsg 响应给客户端的数据结构
type ResponseWriter ¶
type ResponseWriter struct {
http.ResponseWriter
// contains filtered or unexported fields
}
ResponseWriter 增加status字段
func NewResponseWriter ¶
func NewResponseWriter(w http.ResponseWriter) *ResponseWriter
NewResponseWriter 创建新实例
func (*ResponseWriter) AbortWithStatus ¶
func (lrw *ResponseWriter) AbortWithStatus(code int)
AbortWithStatus 记录status
func (*ResponseWriter) Write ¶
func (lrw *ResponseWriter) Write(data []byte) (n int, err error)
Write 记录status
func (*ResponseWriter) WriteHeader ¶
func (lrw *ResponseWriter) WriteHeader(code int)
WriteHeader 记录status
func (*ResponseWriter) WriteString ¶
func (lrw *ResponseWriter) WriteString(s string) (n int, err error)
WriteString 获取Written
type Router ¶
type Router struct {
httprouter.Router
PanicHandler func(*Context)
ResponseHandler func(*Context)
Prefix string
ErrLog *mlog.Logger
// Registry prometheus.Registerer
RequestsInFlight prometheus.Gauge
ConcurrencyLimitExceeded prometheus.Counter
PrometheusList PrometheusList
// contains filtered or unexported fields
}
Router 自定义http router
func (*Router) AddRoute ¶
func (router *Router) AddRoute(method, path string, perm uint, conf interface{}, handlers ...Handle)
AddRoute 增加route信息
func (*Router) PutRouterList ¶
func (router *Router) PutRouterList(rl *RouterList, conf interface{})
PutRouterList 添加routerlist到路由表
func (*Router) ServeHTTP ¶
func (router *Router) ServeHTTP(w http.ResponseWriter, req *http.Request)
ServeHTTP 增加日志输出
func (*Router) SetupPrometheus ¶
func (router *Router) SetupPrometheus()
type RouterList ¶
RouterList api路由列表
Click to show internal directories.
Click to hide internal directories.