gin

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func H

H fractal handler wrapper for gin defaulr handler

Types

type Callback

type Callback func(*Response)

Callback modify response

type Context

type Context struct {
	*gin.Context
	// contains filtered or unexported fields
}

Context gin context with fractal extension

func (*Context) AbortBadRequest

func (c *Context) AbortBadRequest(mods ...ModErrorOption)

AbortBadRequest return a 400 error and abort

func (*Context) AbortForbidden

func (c *Context) AbortForbidden(mods ...ModErrorOption)

AbortForbidden return a 403 error and abort

func (*Context) AbortInternal

func (c *Context) AbortInternal(mods ...ModErrorOption)

AbortInternal return a 500 error and abort

func (*Context) AbortMethodNotAllowed

func (c *Context) AbortMethodNotAllowed(mods ...ModErrorOption)

AbortMethodNotAllowed return a 405 error and abort

func (*Context) AbortNotFound

func (c *Context) AbortNotFound(mods ...ModErrorOption)

AbortNotFound return a 404 error and abort

func (*Context) AbortUnauthorized

func (c *Context) AbortUnauthorized(mods ...ModErrorOption)

AbortUnauthorized return a 401 error and abort

func (*Context) AbortUnprocessable

func (c *Context) AbortUnprocessable(mods ...ModErrorOption)

AbortUnprocessable return a 422 error and abort

func (*Context) Collection

func (c *Context) Collection(items []fractal.Any, transformer fractal.Transformer, callbacks ...Callback)

func (*Context) Error

func (c *Context) Error(opt *ErrorOption, status int)

Error return an error

func (*Context) ErrorBadRequest

func (c *Context) ErrorBadRequest(mods ...ModErrorOption)

ErrorBadRequest return a 400 error

func (*Context) ErrorForbidden

func (c *Context) ErrorForbidden(mods ...ModErrorOption)

ErrorForbidden return a 403 error

func (*Context) ErrorInternal

func (c *Context) ErrorInternal(mods ...ModErrorOption)

ErrorInternal return a 500 error

func (*Context) ErrorMethodNotAllowed

func (c *Context) ErrorMethodNotAllowed(mods ...ModErrorOption)

ErrorMethodNotAllowed return a 405 error

func (*Context) ErrorNotFound

func (c *Context) ErrorNotFound(mods ...ModErrorOption)

ErrorNotFound return a 404 error

func (*Context) ErrorUnauthorized

func (c *Context) ErrorUnauthorized(mods ...ModErrorOption)

ErrorUnauthorized return a 401 error

func (*Context) ErrorUnprocessable

func (c *Context) ErrorUnprocessable(mods ...ModErrorOption)

ErrorUnprocessable return a 422 error

func (*Context) Item

func (c *Context) Item(item fractal.Any, transformer fractal.Transformer, callbacks ...Callback)

func (*Context) NoContent

func (c *Context) NoContent()

func (*Context) Paginator

func (c *Context) Paginator(paginator Paginator, transformer fractal.Transformer, callbacks ...Callback)

type ErrorOption

type ErrorOption struct {
	Message string
	Errors  map[string][]string
}

ErrorOption options for error

type HandlerFunc

type HandlerFunc func(*Context)

HandlerFunc fractal gin handler

type ModErrorOption

type ModErrorOption func(*ErrorOption)

ModErrorOption function to modify error option

func WithError

func WithError(err error) ModErrorOption

WithError change error message by error

func WithMessage

func WithMessage(message string) ModErrorOption

WithMessage change error message

func WithValidatorError

func WithValidatorError(err error, req Request) ModErrorOption

WithError change error message by error

type Paginator

type Paginator interface {
	fractal.Paginator
	GetItems() []interface{}
	SetItems(items []interface{})
}

Paginator paginator with items

type Request

type Request interface {
	Messages() map[string]string
}

Request request with binging

type Response

type Response struct {
	Ctx      *Context
	Fractal  *fractal.Manager
	Resource fractal.Resource
	Status   int
}

Jump to

Keyboard shortcuts

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