Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( Main = gcmd.Command{ Name: "main", Usage: "main", Brief: "start http server", Func: func(ctx context.Context, parser *gcmd.Parser) (err error) { s := g.Server() s.BindHookHandler("/*", ghttp.HookBeforeServe, beforeServeHook) s.Group("/", func(g *ghttp.RouterGroup) { g.Middleware(MiddlewareAuth) g.Middleware(MiddlewareHandlerResponse) g.Bind() }) s.Group("/v1", func(v1 *ghttp.RouterGroup) { v1.Middleware(MiddlewareAuth) v1.Middleware(MiddlewareHandlerResponse) v1.Group("/chat", func(g *ghttp.RouterGroup) { g.Bind( chat.NewV1(), ) }) v1.Group("/token", func(g *ghttp.RouterGroup) { g.Bind( token.NewV1(), ) }) }) s.Run() return nil }, } )
Functions ¶
func MiddlewareAuth ¶
func MiddlewareHandlerResponse ¶
MiddlewareHandlerResponse is the default middleware handling handler response object and its error.
Types ¶
type DefaultHandlerResponse ¶
type DefaultHandlerResponse struct { Code int `json:"code" dc:"Error code"` Message string `json:"message" dc:"Error message"` Data interface{} `json:"data" dc:"Result data for certain request according API definition"` }
DefaultHandlerResponse is the default implementation of HandlerResponse.
Click to show internal directories.
Click to hide internal directories.