Documentation ¶
Index ¶
- Constants
- Variables
- func CreateTestContext(w http.ResponseWriter) (*Context, *Engine)
- func DebugRoute(router *Engine, path ...string)
- func DebugWithRouteGroup(router *RouterGroup)
- func HandlerFunc(h Handler) gin.HandlerFunc
- func SetDebugToken(token string)
- func SetMode(value string)
- type AuthFunc
- type Client
- type ClientOption
- type Context
- func (c *Context) BindJSON(obj any) error
- func (c *Context) GetBody() ([]byte, error)
- func (c *Context) JSON(data any) error
- func (c *Context) Redirect(location string) error
- func (c *Context) RequestId() string
- func (c *Context) ShouldBindBodyJSON(obj any) error
- func (c *Context) ShouldBindJSON(obj any) error
- func (c *Context) ShouldBindQuery(obj any) error
- func (c *Context) ShouldBindUri(obj any) error
- func (c *Context) Status(status int)
- func (c *Context) String(format string, values ...any) error
- func (c *Context) XML(data any) error
- func (c *Context) YAML(data any) error
- type Engine
- type ErrorDecoderFunc
- type H
- type Handler
- type IRoutes
- type Response
- type RouterGroup
- func (r *RouterGroup) Any(relativePath string, handlers ...Handler) IRoutes
- func (r *RouterGroup) DELETE(relativePath string, handlers ...Handler) IRoutes
- func (r *RouterGroup) GET(relativePath string, handlers ...Handler) IRoutes
- func (r *RouterGroup) Group(relativePath string, handlers ...Handler) *RouterGroup
- func (r *RouterGroup) HEAD(relativePath string, handlers ...Handler) IRoutes
- func (r *RouterGroup) Handle(method string, relativePath string, handlers ...Handler) IRoutes
- func (r *RouterGroup) OPTIONS(relativePath string, handlers ...Handler) IRoutes
- func (r *RouterGroup) PATCH(relativePath string, handlers ...Handler) IRoutes
- func (r *RouterGroup) POST(relativePath string, handlers ...Handler) IRoutes
- func (r *RouterGroup) PUT(relativePath string, handlers ...Handler) IRoutes
- func (r *RouterGroup) Use(middleware ...Handler) IRoutes
- type TestRequest
- func (r *TestRequest) BeforeHook(fn func(req *http.Request))
- func (r *TestRequest) Form(values *url.Values) (*TestResponse, error)
- func (r *TestRequest) Get() (*TestResponse, error)
- func (r *TestRequest) JSON(data any) (*TestResponse, error)
- func (r *TestRequest) Post(contentType string, body io.Reader) (*TestResponse, error)
- func (r *TestRequest) XML(body string) (*TestResponse, error)
- type TestResponse
Constants ¶
View Source
const ( // DebugMode indicates gin mode is debug. DebugMode = gin.DebugMode // ReleaseMode indicates gin mode is release. ReleaseMode = gin.ReleaseMode // TestMode indicates gin mode is test. TestMode = gin.TestMode )
View Source
const ( JsonContentType = "application/json; charset=utf-8" FormContentType = "application/x-www-form-urlencoded; charset=utf-8" XmlContentType = "application/xml; charset=utf-8" TextContentType = "text/plain; charset=utf-8" )
Variables ¶
View Source
var ErrorHandler = func(c *Context, err error) error {
c.Abort()
return c.String(err.Error())
}
Functions ¶
func CreateTestContext ¶ added in v1.4.0
func CreateTestContext(w http.ResponseWriter) (*Context, *Engine)
func DebugRoute ¶
func DebugWithRouteGroup ¶ added in v1.4.1
func DebugWithRouteGroup(router *RouterGroup)
func HandlerFunc ¶
func HandlerFunc(h Handler) gin.HandlerFunc
func SetDebugToken ¶ added in v1.4.1
func SetDebugToken(token string)
Types ¶
type Client ¶ added in v1.6.0
type Client struct { Endpoint string // contains filtered or unexported fields }
Client is an HTTP client.
type ClientOption ¶ added in v1.6.0
type ClientOption func(c *clientOptions)
func WithAuthorization ¶ added in v1.6.0
func WithAuthorization(fn AuthFunc) ClientOption
func WithErrorDecoder ¶ added in v1.6.0
func WithErrorDecoder(errorDecoder ErrorDecoderFunc) ClientOption
func WithTimeout ¶ added in v1.6.0
func WithTimeout(t time.Duration) ClientOption
type Context ¶
func (*Context) ShouldBindBodyJSON ¶ added in v1.1.3
func (*Context) ShouldBindJSON ¶
func (*Context) ShouldBindQuery ¶ added in v1.7.0
func (*Context) ShouldBindUri ¶ added in v1.7.0
type Engine ¶ added in v1.3.0
type Engine struct { *gin.Engine RouterGroup }
type ErrorDecoderFunc ¶ added in v1.6.0
type H ¶ added in v1.3.0
H is a shortcut for map[string]interface{}
func (H) MarshalXML ¶ added in v1.3.0
MarshalXML allows type H to be used with xml.Marshal.
type IRoutes ¶ added in v1.3.0
type IRoutes interface { Use(...Handler) IRoutes Any(string, ...Handler) IRoutes GET(string, ...Handler) IRoutes POST(string, ...Handler) IRoutes DELETE(string, ...Handler) IRoutes PATCH(string, ...Handler) IRoutes PUT(string, ...Handler) IRoutes OPTIONS(string, ...Handler) IRoutes HEAD(string, ...Handler) IRoutes }
IRoutes defines all router handle interface.
type Response ¶
type Response struct { gin.ResponseWriter // contains filtered or unexported fields }
type RouterGroup ¶ added in v1.3.0
type RouterGroup struct {
*gin.RouterGroup
}
func (*RouterGroup) Any ¶ added in v1.3.0
func (r *RouterGroup) Any(relativePath string, handlers ...Handler) IRoutes
func (*RouterGroup) DELETE ¶ added in v1.3.0
func (r *RouterGroup) DELETE(relativePath string, handlers ...Handler) IRoutes
func (*RouterGroup) GET ¶ added in v1.3.0
func (r *RouterGroup) GET(relativePath string, handlers ...Handler) IRoutes
func (*RouterGroup) Group ¶ added in v1.3.0
func (r *RouterGroup) Group(relativePath string, handlers ...Handler) *RouterGroup
func (*RouterGroup) HEAD ¶ added in v1.3.0
func (r *RouterGroup) HEAD(relativePath string, handlers ...Handler) IRoutes
func (*RouterGroup) Handle ¶ added in v1.4.0
func (r *RouterGroup) Handle(method string, relativePath string, handlers ...Handler) IRoutes
func (*RouterGroup) OPTIONS ¶ added in v1.3.0
func (r *RouterGroup) OPTIONS(relativePath string, handlers ...Handler) IRoutes
func (*RouterGroup) PATCH ¶ added in v1.3.0
func (r *RouterGroup) PATCH(relativePath string, handlers ...Handler) IRoutes
func (*RouterGroup) POST ¶ added in v1.3.0
func (r *RouterGroup) POST(relativePath string, handlers ...Handler) IRoutes
func (*RouterGroup) PUT ¶ added in v1.3.0
func (r *RouterGroup) PUT(relativePath string, handlers ...Handler) IRoutes
func (*RouterGroup) Use ¶ added in v1.3.0
func (r *RouterGroup) Use(middleware ...Handler) IRoutes
type TestRequest ¶ added in v1.6.0
func NewTestRequest ¶ added in v1.6.0
func NewTestRequest(url string, handlers ...Handler) *TestRequest
func NewTestRequestWithPath ¶ added in v1.6.0
func NewTestRequestWithPath(path, url string, handlers ...Handler) *TestRequest
func (*TestRequest) BeforeHook ¶ added in v1.6.0
func (r *TestRequest) BeforeHook(fn func(req *http.Request))
func (*TestRequest) Form ¶ added in v1.6.0
func (r *TestRequest) Form(values *url.Values) (*TestResponse, error)
func (*TestRequest) Get ¶ added in v1.6.0
func (r *TestRequest) Get() (*TestResponse, error)
func (*TestRequest) JSON ¶ added in v1.6.0
func (r *TestRequest) JSON(data any) (*TestResponse, error)
func (*TestRequest) Post ¶ added in v1.6.0
func (r *TestRequest) Post(contentType string, body io.Reader) (*TestResponse, error)
func (*TestRequest) XML ¶ added in v1.6.0
func (r *TestRequest) XML(body string) (*TestResponse, error)
type TestResponse ¶ added in v1.6.0
type TestResponse struct {
*httptest.ResponseRecorder
}
func (*TestResponse) GetBody ¶ added in v1.6.0
func (r *TestResponse) GetBody() []byte
func (*TestResponse) GetBodyString ¶ added in v1.6.0
func (r *TestResponse) GetBodyString() string
func (*TestResponse) GetJson ¶ added in v1.6.0
func (r *TestResponse) GetJson() gjson.Result
func (*TestResponse) GetJsonPath ¶ added in v1.6.0
func (r *TestResponse) GetJsonPath(path string) gjson.Result
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
cmd
|
|
protoc-gen-go-gee-errors
Module
|
|
protoc-gen-go-gee-http
Module
|
|
proto
Package proto defines the protobuf codec.
|
Package proto defines the protobuf codec. |
nolint:gomnd
|
nolint:gomnd |
example
module
|
|
middleware
|
|
Click to show internal directories.
Click to hide internal directories.