Documentation ¶
Index ¶
- func Bind(c *gin.Context, obj interface{}) error
- func BindJSON(c *gin.Context, obj interface{}) error
- func BindQuery(c *gin.Context, obj interface{}) error
- func BindXML(c *gin.Context, obj interface{}) error
- func BindYAML(c *gin.Context, obj interface{}) error
- func Convert(handler http.HandlerFunc) gin.HandlerFunc
- func Converts(handlers []http.HandlerFunc) []gin.HandlerFunc
- func Debug(r *gin.Engine)
- func FromStdWithNext(h func(w http.ResponseWriter, r *http.Request, next http.HandlerFunc)) gin.HandlerFunc
- func MustBindWith(c *gin.Context, obj interface{}, b binding.Binding) error
- func NewReq[REQ any](c *gin.Context) (*REQ, error)
- func OpenApi(mux *gin.Engine, filePath string)
- func RespErr(ctx *gin.Context, err error)
- func RespErrMsg(ctx *gin.Context, msg string)
- func RespErrRep(ctx *gin.Context, rep *errorcode.ErrRep)
- func RespErrcode(ctx *gin.Context, code errorcode.ErrCode)
- func Response(ctx *gin.Context, code errorcode.ErrCode, msg string, data interface{})
- func ShouldBind(c *gin.Context, obj interface{}) error
- func ShouldBindBodyWith(c *gin.Context, obj interface{}, bb binding.BindingBody) (err error)
- func ShouldBindJSON(c *gin.Context, obj interface{}) error
- func ShouldBindQuery(c *gin.Context, obj interface{}) error
- func ShouldBindUri(r *gin.Context, obj interface{}) error
- func ShouldBindWith(c *gin.Context, obj interface{}, b binding.Binding) error
- func ShouldBindXML(c *gin.Context, obj interface{}) error
- func ShouldBindYAML(c *gin.Context, obj interface{}) error
- func Wrap(handler interface{}) gin.HandlerFunc
- type Config
- type ExportService
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Convert ¶ added in v1.3.0
func Convert(handler http.HandlerFunc) gin.HandlerFunc
func Converts ¶ added in v1.3.0
func Converts(handlers []http.HandlerFunc) []gin.HandlerFunc
func FromStdWithNext ¶ added in v1.3.0
func FromStdWithNext(h func(w http.ResponseWriter, r *http.Request, next http.HandlerFunc)) gin.HandlerFunc
func MustBindWith ¶
MustBindWith binds the passed struct pointer using the specified binding engine. It will abort the request with HTTP 400 if any error occurs. See the binding package.
func RespErrMsg ¶ added in v1.3.0
func ShouldBind ¶
ShouldBind checks the Content-Type to select a binding engine automatically, Depending the "Content-Type" header different bindings are used:
"application/json" --> JSON binding "application/xml" --> XML binding
otherwise --> returns an error It parses the request's body as JSON if Content-Type == "application/json" using JSON or XML as a JSON input. It decodes the json payload into the struct specified as a pointer. Like c.GinBind() but this method does not set the response status code to 400 and abort if the json is not valid.
func ShouldBindBodyWith ¶
func ShouldBindBodyWith(c *gin.Context, obj interface{}, bb binding.BindingBody) (err error)
ShouldBindBodyWith is similar with ShouldBindWith, but it stores the request body into the context, and reuse when it is called again.
NOTE: This method reads the body before binding. So you should use ShouldBindWith for better performance if you need to call only once.
func ShouldBindJSON ¶
ShouldBindJSON is a shortcut for c.ShouldBindWith(obj, binding.JSON).
func ShouldBindQuery ¶
ShouldBindQuery is a shortcut for c.ShouldBindWith(obj, binding.Query).
func ShouldBindUri ¶
ShouldBindUri binds the passed struct pointer using the specified binding engine.
func ShouldBindWith ¶
ShouldBindWith binds the passed struct pointer using the specified binding engine. See the binding package.
func ShouldBindXML ¶
ShouldBindXML is a shortcut for c.ShouldBindWith(obj, binding.XML).
func ShouldBindYAML ¶
ShouldBindYAML is a shortcut for c.ShouldBindWith(obj, binding.YAML).
func Wrap ¶ added in v1.3.0
func Wrap(handler interface{}) gin.HandlerFunc
Wrap converts native http.Handler & http.HandlerFunc to gin.HandlerFunc.
Supported form types:
.Wrap(h http.Handler) .Wrap(func(w http.ResponseWriter, r *http.Request)) .Wrap(func(w http.ResponseWriter, r *http.Request, next http.HandlerFunc))
Types ¶
type ExportService ¶ added in v1.3.0
type ExportService struct{}