res

package
v0.0.0-...-db88944 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Accepted

func Accepted(w http.ResponseWriter, v any)

func BadRequest

func BadRequest(w http.ResponseWriter, code, message string, errs ...string)

func Created

func Created(w http.ResponseWriter, v any)

func Forbidden

func Forbidden(w http.ResponseWriter, code, message string, errs ...string)

func HTML

func HTML(w http.ResponseWriter, status int, name string, v any)

func InternalServerError

func InternalServerError(w http.ResponseWriter, code, message string, errs ...string)

func JSON

func JSON(w http.ResponseWriter, status int, v any)

func NewErr

func NewErr(w http.ResponseWriter, err *ErrResponse)

func NoContent

func NoContent(w http.ResponseWriter)

func NotFound

func NotFound(w http.ResponseWriter, code, message string, errs ...string)

func OK

func OK(w http.ResponseWriter, v any)

func PageOf

func PageOf(w http.ResponseWriter, v any, page, size, total int)

func PartialContent

func PartialContent(w http.ResponseWriter, v any)

func Unauthorized

func Unauthorized(w http.ResponseWriter, code, message string, errs ...string)

func UnprocessableEntity

func UnprocessableEntity(w http.ResponseWriter, code, message string, errs ...string)

Types

type ErrResponse

type ErrResponse struct {
	Error   errDTO   `json:"error"`
	Details []errDTO `json:"details,omitempty"`
}

func NewErrResponse

func NewErrResponse(status int, code, message string, errs ...string) *ErrResponse

type M

type M map[string]any

M is a convenience alias for quickly building a map structure that is going out to a responder. Just a short-hand.

type Meta

type Meta struct {
	Page Page `json:"page,omitempty"`
}

type Response

type Response struct {
	Meta any `json:"meta,omitempty"`
	Data any `json:"data"`
}

func NewPageableResponse

func NewPageableResponse(data any, page, size, total int) Response

func NewResponse

func NewResponse(data any) Response

Jump to

Keyboard shortcuts

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