Documentation ¶
Index ¶
- Constants
- Variables
- func BindModel(req interface{}) gin.HandlerFunc
- func CookiesParser(c *gin.Context, model interface{}) error
- func NewHub() *hub
- func RegisterGroup(engine *gin.Engine, group *RouterGroup)
- func RegisterGroupSimple(engine *gin.Engine, Relative string, Middlewares []gin.HandlerFunc, ...)
- func RegisterHandler(engine *gin.Engine, handlers ...RouterHandler)
- type ApiKey
- type Basic
- type Bearer
- type Client
- type ContentTypeType
- type EnginX
- func (g *EnginX) AfterInit(f func())
- func (g *EnginX) BeforeInit(f func())
- func (g *EnginX) DELETE(path string, handler gin.HandlerFunc)
- func (g *EnginX) GET(path string, handler gin.HandlerFunc)
- func (g *EnginX) Group(path string, options ...Option) *Group
- func (g *EnginX) HEAD(path string, handler gin.HandlerFunc)
- func (g *EnginX) Handle(path string, method string, r *Router)
- func (g *EnginX) Init()
- func (g *EnginX) Mount(path string, app *EnginX)
- func (g *EnginX) OPTIONS(path string, handler gin.HandlerFunc)
- func (g *EnginX) PATCH(path string, handler gin.HandlerFunc)
- func (g *EnginX) POST(path string, handler gin.HandlerFunc)
- func (g *EnginX) PUT(path string, handler gin.HandlerFunc)
- func (g *EnginX) Register(spec interface{}, middlewares ...gin.HandlerFunc)
- func (g *EnginX) RegisterAll(spec ...interface{})
- func (g *EnginX) Run(addr string) error
- func (g *EnginX) WithErrorHandler(handler ErrorHandlerFunc) *EnginX
- type EnginxOpt
- func WithGlobalMiddleware(middlewares ...gin.HandlerFunc) EnginxOpt
- func WithGlobalMiddlewareByName(middlewares ...string) EnginxOpt
- func WithLog(logger *logger.ZapX) EnginxOpt
- func WithSwagger(swagger *Swagger) EnginxOpt
- func WithWS() EnginxOpt
- func WithWebStatic(dist *embed.FS, prefix string) EnginxOpt
- type ErrorHandlerFunc
- type Group
- func (g *Group) DELETE(path string, router *Router)
- func (g *Group) GET(path string, router *Router)
- func (g *Group) Group(path string, options ...Option) *Group
- func (g *Group) HEAD(path string, router *Router)
- func (g *Group) Handle(path string, method string, r *Router)
- func (g *Group) OPTIONS(path string, router *Router)
- func (g *Group) PATCH(path string, router *Router)
- func (g *Group) POST(path string, router *Router)
- func (g *Group) PUT(path string, router *Router)
- type Handler
- func (Handler) Bind(ctx *gin.Context, val interface{}) error
- func (b *Handler) DoJson(ctx *gin.Context, code types.ResponseCode, groups []string, data interface{})
- func (b *Handler) DoReq(ctx *gin.Context, typ_ reqType, req interface{}) error
- func (b *Handler) DoRes(ctx *gin.Context, code types.ResponseCode, ext interface{})
- func (b *Handler) Parse(ctx *gin.Context, req interface{}) error
- func (b *Handler) WS(ctx *gin.Context) (*Client, error)
- type ISecurity
- type Model
- type OAuth2
- type OpenID
- type Option
- type Response
- type ResponseItem
- type Router
- func (router *Router) GetHandlers() []gin.HandlerFunc
- func (router *Router) WithContentType(contentType string, contentTypeType ContentTypeType) *Router
- func (router *Router) WithDeprecated() *Router
- func (router *Router) WithDescription(description string) *Router
- func (router *Router) WithExclude() *Router
- func (router *Router) WithHandlers(handlers ...gin.HandlerFunc) *Router
- func (router *Router) WithOperationID(ID string) *Router
- func (router *Router) WithResponses(response Response) *Router
- func (router *Router) WithSecurity(securities ...ISecurity) *Router
- func (router *Router) WithSummary(summary string) *Router
- func (router *Router) WithTags(tags ...string) *Router
- type RouterGroup
- type RouterHandler
- type RouterOption
- func ContentType(contentType string, contentTypeType ContentTypeType) RouterOption
- func Deprecated() RouterOption
- func Description(description string) RouterOption
- func Exclude() RouterOption
- func Handlers(handlers ...gin.HandlerFunc) RouterOption
- func OperationID(ID string) RouterOption
- func Responses(response Response) RouterOption
- func RouterSecurity(securities ...ISecurity) RouterOption
- func Summary(summary string) RouterOption
- func Tags(tags ...string) RouterOption
- type Security
- type Swagger
- func (swagger *Swagger) BuildOpenAPI()
- func (swagger *Swagger) MarshalJSON() ([]byte, error)
- func (swagger *Swagger) MarshalYAML() ([]byte, error)
- func (swagger *Swagger) WithContact(contact *openapi3.Contact) *Swagger
- func (swagger *Swagger) WithDescription(description string) *Swagger
- func (swagger *Swagger) WithDocsUrl(url string) *Swagger
- func (swagger *Swagger) WithExtraOpenApi(extraurl string, middlewares ...gin.HandlerFunc) *Swagger
- func (swagger *Swagger) WithLicense(license *openapi3.License) *Swagger
- func (swagger *Swagger) WithOpenAPIUrl(url string) *Swagger
- func (swagger *Swagger) WithRedocOptions(options map[string]interface{}) *Swagger
- func (swagger *Swagger) WithRedocUrl(url string) *Swagger
- func (swagger *Swagger) WithServers(servers []*openapi3.Server) *Swagger
- func (swagger *Swagger) WithSwaggerOptions(options map[string]interface{}) *Swagger
- func (swagger *Swagger) WithTermsOfService(termsOfService string) *Swagger
- func (swagger *Swagger) WithTitle(title string) *Swagger
- func (swagger *Swagger) WithVersion(version string) *Swagger
- type SwaggerOption
- func Contact(Contact *openapi3.Contact) SwaggerOption
- func DocsUrl(url string) SwaggerOption
- func License(License *openapi3.License) SwaggerOption
- func OpenAPIUrl(url string) SwaggerOption
- func RedocOptions(options map[string]interface{}) SwaggerOption
- func RedocUrl(url string) SwaggerOption
- func Routers(routers map[string]map[string]*Router) SwaggerOption
- func Servers(servers openapi3.Servers) SwaggerOption
- func SwagDescription(description string) SwaggerOption
- func SwaggerOptions(options map[string]interface{}) SwaggerOption
- func TermsOfService(TermsOfService string) SwaggerOption
- func Title(title string) SwaggerOption
- func Version(version string) SwaggerOption
- type User
Constants ¶
View Source
const ( Nil reqType = iota JSON XML Form Query FormPost FormMultipart ProtoBuf MsgPack YAML Uri Header TOML )
View Source
const ( Credentials = "credentials" BasicAuth = "BasicAuth" BearerAuth = "BearerAuth" ApiKeyAuth = "ApiKeyAuth" OpenIDAuth = "OpenIDAuth" OAuth2Auth = "OAuth2Auth" )
View Source
const ( DEFAULT = "default" BINDING = "binding" DESCRIPTION = "description" QUERY = "query" FORM = "form" URI = "uri" HEADER = "header" COOKIE = "cookie" )
Variables ¶
View Source
var ( ErrNotFound = errors.New("no this record") ErrInsert = errors.New("insert fail") ErrUpdate = errors.New("update fail") ErrDelete = errors.New("delete fail") )
各类错误类型
View Source
var RQuery = queryBinding{}
Functions ¶
func BindModel ¶
func BindModel(req interface{}) gin.HandlerFunc
func CookiesParser ¶
func RegisterGroup ¶
func RegisterGroup(engine *gin.Engine, group *RouterGroup)
func RegisterGroupSimple ¶
func RegisterGroupSimple(engine *gin.Engine, Relative string, Middlewares []gin.HandlerFunc, Handlers []RouterHandler)
func RegisterHandler ¶
func RegisterHandler(engine *gin.Engine, handlers ...RouterHandler)
Types ¶
type Basic ¶
type Basic struct {
Security
}
func (*Basic) Scheme ¶
func (b *Basic) Scheme() *openapi3.SecurityScheme
type Client ¶
type Client struct { Hub *hub // contains filtered or unexported fields }
Client is a middleman between the websocket connection and the hub.
type ContentTypeType ¶
type ContentTypeType string
var ( ContentTypeRequest ContentTypeType = "request" ContentTypeResponse ContentTypeType = "response" )
type EnginX ¶
type EnginX struct { *gin.Engine Routers map[string]map[string]*Router ErrorHandler ErrorHandlerFunc // contains filtered or unexported fields }
func (*EnginX) BeforeInit ¶
func (g *EnginX) BeforeInit(f func())
func (*EnginX) Register ¶
func (g *EnginX) Register(spec interface{}, middlewares ...gin.HandlerFunc)
func (*EnginX) RegisterAll ¶
func (g *EnginX) RegisterAll(spec ...interface{})
func (*EnginX) WithErrorHandler ¶
func (g *EnginX) WithErrorHandler(handler ErrorHandlerFunc) *EnginX
type EnginxOpt ¶
type EnginxOpt func(*EnginX)
func WithGlobalMiddleware ¶
func WithGlobalMiddleware(middlewares ...gin.HandlerFunc) EnginxOpt
func WithSwagger ¶
type Group ¶
type Handler ¶
type Handler struct { Method string `default:"GET"` Description string `default:"no description"` Tags []string `default:"default"` ContentType string `default:"json"` Security string `default:"null"` Middlewares string Request struct{} Response200 struct { Code int `json:"code"` Msg string `json:"msg"` } `type:"application/json"` Response500 struct { Code int `json:"code"` Msg string `json:"msg"` Detail string `json:"detail"` } `type:"application/json"` }
put this in common
type CommonSuccResponse struct { Code int `json:"code"` Msg string `json:"msg"` }
type CommonFailResponse struct { Code int `json:"code"` Msg string `json:"msg"` Detail string `json:"detail"` }
this is a snippet @Summary (概要) @Description (描述) @Tags (tag) @Accept (请求类型: json|form) @Produce (响应类型: json) @Param token header string true "-" @Param req (参数类型: body | header | form | query) (数据类型) true "-" @Success 200 {object} CommonSuccRespons @Failure 500 {object} CommonFailResponse @Router (url) [ ( get | post | put) ]
type OAuth2 ¶
type OAuth2 struct { Security AuthorizationURL string TokenURL string RefreshURL string Scopes map[string]string }
func (*OAuth2) Scheme ¶
func (i *OAuth2) Scheme() *openapi3.SecurityScheme
type Option ¶
type Option func(*Group)
func GroupHandlers ¶
func GroupHandlers(handlers ...gin.HandlerFunc) Option
func GroupSecurity ¶
type Response ¶
type Response map[string]ResponseItem
type ResponseItem ¶
type Router ¶
type Router struct { Handlers *list.List Path string Method string Summary string Description string Deprecated bool RequestContentType string // ResponseContentType string Tags []string API gin.HandlerFunc Model Model OperationID string Exclude bool Securities []ISecurity Response Response }
func NewRouter ¶
func NewRouter(f gin.HandlerFunc, options ...RouterOption) *Router
func RouterNew ¶
func RouterNew[T Model, F func(c *gin.Context, req T)](f F, options ...RouterOption) *Router
func RouterNewNew ¶
func RouterNewNew(val interface{}, fn gin.HandlerFunc) *Router
func (*Router) GetHandlers ¶
func (router *Router) GetHandlers() []gin.HandlerFunc
func (*Router) WithContentType ¶
func (router *Router) WithContentType(contentType string, contentTypeType ContentTypeType) *Router
func (*Router) WithDeprecated ¶
func (*Router) WithDescription ¶
func (*Router) WithExclude ¶
func (*Router) WithHandlers ¶
func (router *Router) WithHandlers(handlers ...gin.HandlerFunc) *Router
func (*Router) WithOperationID ¶
func (*Router) WithResponses ¶
func (*Router) WithSecurity ¶
func (*Router) WithSummary ¶
type RouterGroup ¶
type RouterGroup struct { Relative string Middlewares []gin.HandlerFunc Handler []RouterHandler }
type RouterHandler ¶
type RouterHandler struct { Method string Url string Handler gin.HandlerFunc Middleware []gin.HandlerFunc }
func H ¶
func H(method string, url string, handler gin.HandlerFunc, middleware []gin.HandlerFunc) RouterHandler
func HDefault ¶
func HDefault(v interface{}) (handlers []RouterHandler)
type RouterOption ¶
type RouterOption func(router *Router)
func ContentType ¶
func ContentType(contentType string, contentTypeType ContentTypeType) RouterOption
ContentType Set request contentType
func Description ¶
func Description(description string) RouterOption
func Handlers ¶
func Handlers(handlers ...gin.HandlerFunc) RouterOption
func OperationID ¶
func OperationID(ID string) RouterOption
func Responses ¶
func Responses(response Response) RouterOption
func RouterSecurity ¶
func RouterSecurity(securities ...ISecurity) RouterOption
func Summary ¶
func Summary(summary string) RouterOption
func Tags ¶
func Tags(tags ...string) RouterOption
type Swagger ¶
type Swagger struct { Title string Description string Version string DocsUrl string RedocUrl string OpenAPIUrl string ExtraOpenAPIUrl string OpenAPIMiddleware []gin.HandlerFunc Routers map[string]map[string]*Router Servers openapi3.Servers TermsOfService string Contact *openapi3.Contact License *openapi3.License OpenAPI *openapi3.T SwaggerOptions map[string]interface{} RedocOptions map[string]interface{} }
func New ¶
func New(title, description, version string, options ...SwaggerOption) *Swagger
func (*Swagger) BuildOpenAPI ¶
func (swagger *Swagger) BuildOpenAPI()
func (*Swagger) MarshalJSON ¶
func (*Swagger) MarshalYAML ¶
func (*Swagger) WithContact ¶
func (*Swagger) WithDescription ¶
func (*Swagger) WithDocsUrl ¶
func (*Swagger) WithExtraOpenApi ¶
func (swagger *Swagger) WithExtraOpenApi(extraurl string, middlewares ...gin.HandlerFunc) *Swagger
func (*Swagger) WithLicense ¶
func (*Swagger) WithOpenAPIUrl ¶
func (*Swagger) WithRedocOptions ¶
func (*Swagger) WithRedocUrl ¶
func (*Swagger) WithServers ¶
func (*Swagger) WithSwaggerOptions ¶
func (*Swagger) WithTermsOfService ¶
func (*Swagger) WithVersion ¶
type SwaggerOption ¶
type SwaggerOption func(swagger *Swagger)
func Contact ¶
func Contact(Contact *openapi3.Contact) SwaggerOption
func DocsUrl ¶
func DocsUrl(url string) SwaggerOption
func License ¶
func License(License *openapi3.License) SwaggerOption
func OpenAPIUrl ¶
func OpenAPIUrl(url string) SwaggerOption
func RedocOptions ¶
func RedocOptions(options map[string]interface{}) SwaggerOption
func RedocUrl ¶
func RedocUrl(url string) SwaggerOption
func Servers ¶
func Servers(servers openapi3.Servers) SwaggerOption
func SwagDescription ¶
func SwagDescription(description string) SwaggerOption
func SwaggerOptions ¶
func SwaggerOptions(options map[string]interface{}) SwaggerOption
func TermsOfService ¶
func TermsOfService(TermsOfService string) SwaggerOption
func Title ¶
func Title(title string) SwaggerOption
func Version ¶
func Version(version string) SwaggerOption
Source Files ¶
Click to show internal directories.
Click to hide internal directories.