gini

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2019 License: MIT Imports: 10 Imported by: 0

README

gini

Documentation License Build Status Go Report Card Issues

Toolkit to work better with go-gin

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bind

func Bind(ctx *gin.Context, v interface{}) error

Bind to parse request body to struct.

func DumpReqAndResp

func DumpReqAndResp() gin.HandlerFunc

DumpReqAndResp dumps request and response. NOTICE: it will be expose some sensitive data.

func JSONRenderWrap

func JSONRenderWrap(next func(*gin.Context) error) gin.HandlerFunc

JSONRenderWrap to write valid response.

func RegisterError

func RegisterError(err error, status int, desc string)

RegisterError register error to RenderWrap

func SetBinder

func SetBinder(b Binder)

SetBinder set Binder instance.

Types

type Binder

type Binder interface {
	Bind(*gin.Context, interface{}) error
}

Binder to parse request body to struct.

type JSONRenderBody

type JSONRenderBody struct {
	Status int         `json:"status"`
	Msg    string      `json:"msg"`
	Data   interface{} `json:"data"`
}

RenderBody json render layout.

type MockJSONBinder

type MockJSONBinder struct {
	// contains filtered or unexported fields
}

MockJSONBinder json binder for mock.

func (*MockJSONBinder) Bind

func (mb *MockJSONBinder) Bind(c *gin.Context, v interface{}) error

Bind for Binder interface.

func (*MockJSONBinder) Body

func (mb *MockJSONBinder) Body(body string)

Body set request body

Jump to

Keyboard shortcuts

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