gini

package
v1.2.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 6, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bind

func Bind(c *gin.Context, obj interface{}) error

func BindJSON

func BindJSON(c *gin.Context, obj interface{}) error

BindJSON is a shortcut for c.MustBindWith(obj, binding.JSON).

func BindQuery

func BindQuery(c *gin.Context, obj interface{}) error

BindQuery is a shortcut for c.MustBindWith(obj, binding.Query).

func BindXML

func BindXML(c *gin.Context, obj interface{}) error

BindXML is a shortcut for c.MustBindWith(obj, binding.BindXML).

func BindYAML

func BindYAML(c *gin.Context, obj interface{}) error

BindYAML is a shortcut for c.MustBindWith(obj, binding.YAML).

func Debug

func Debug(r *gin.Engine)

func Http

func Http(conf *Config, ginHandle func(engine *gin.Engine)) *gin.Engine

func MustBindWith

func MustBindWith(c *gin.Context, obj interface{}, b binding.Binding) error

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 OpenApi

func OpenApi(mux *gin.Engine, filePath string)

func ShouldBind

func ShouldBind(c *gin.Context, obj interface{}) error

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

func ShouldBindJSON(c *gin.Context, obj interface{}) error

ShouldBindJSON is a shortcut for c.ShouldBindWith(obj, binding.JSON).

func ShouldBindQuery

func ShouldBindQuery(c *gin.Context, obj interface{}) error

ShouldBindQuery is a shortcut for c.ShouldBindWith(obj, binding.Query).

func ShouldBindWith

func ShouldBindWith(c *gin.Context, obj interface{}, b binding.Binding) error

ShouldBindWith binds the passed struct pointer using the specified binding engine. See the binding package.

func ShouldBindXML

func ShouldBindXML(c *gin.Context, obj interface{}) error

ShouldBindXML is a shortcut for c.ShouldBindWith(obj, binding.XML).

func ShouldBindYAML

func ShouldBindYAML(c *gin.Context, obj interface{}) error

ShouldBindYAML is a shortcut for c.ShouldBindWith(obj, binding.YAML).

Types

type Config

type Config struct {
	RedirectTrailingSlash bool

	RedirectFixedPath bool

	HandleMethodNotAllowed bool
	ForwardedByClientIP    bool

	AppEngine bool

	UseRawPath bool

	UnescapePathValues bool

	MaxMultipartMemory int64

	RemoveExtraSlash bool
}

func (*Config) SetConfig

func (c *Config) SetConfig(engine *gin.Engine)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL