responses

package
v0.4.3 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2022 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BadRequest

func BadRequest(c *gin.Context, errors ...Error)

BadRequest sets the HTTP response status to 400

func CannotBind

func CannotBind(c *gin.Context, err error)

CannotBind sets the HTTP response status to 400

func Conflict

func Conflict(c *gin.Context, errors ...Error)

Conflict sets the HTTP response status to 409

func Created

func Created(c *gin.Context, data any)

Created sets the HTTP response status to 201

func Forbidden

func Forbidden(c *gin.Context, errors ...Error)

Forbidden sets the HTTP response status to 403

func FromError added in v0.0.15

func FromError(c *gin.Context, err error)

func InternalError

func InternalError(c *gin.Context, errors ...Error)

InternalError sets the HTTP response status to 500

func NotFound

func NotFound(c *gin.Context, errors ...Error)

NotFound sets the HTTP response status to 404

func Ok

func Ok(c *gin.Context, data any)

func OkWithMeta

func OkWithMeta(c *gin.Context, data any, metadata any)

OkWithMeta sets the HTTP response status to 200

func Timeout

func Timeout(c *gin.Context)

Timeout sets the HTTP response status to 408

func Unauthorized

func Unauthorized(c *gin.Context, errors ...Error)

Unauthorized sets the HTTP response status to 401

func Unavailable

func Unavailable(c *gin.Context, errors ...Error)

Unavailable sets the HTTP response status to 503

Types

type Error

type Error struct {
	Type    string `json:"type,omitempty"`
	Message string `json:"message"`
	Data    any    `json:"data,omitempty"`
}

func NewError

func NewError(err error) Error

func NewErrors

func NewErrors(errs ...error) []Error

type ErrorResponse

type ErrorResponse struct {
	Message string  `json:"message,omitempty"`
	Errors  []Error `json:"errors,omitempty"`
}

type SuccessResponse

type SuccessResponse struct {
	Data any `json:"data"`
}

Jump to

Keyboard shortcuts

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