util

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BadRequest

func BadRequest(err error)

func Bind

func Bind(r *http.Request, dto any)

func Created

func Created(w http.ResponseWriter, location string)

func Forbidden

func Forbidden(err error)

func GetCriteria

func GetCriteria(r *http.Request) mongoext.Criteria

func GetId

func GetId(r *http.Request) string

func IsDebug

func IsDebug(log *zap.Logger) bool

func JSON

func JSON(w http.ResponseWriter, code int, data any)

func NoContent

func NoContent(w http.ResponseWriter)

func OK

func OK(w http.ResponseWriter, data any)

func Unauthorized

func Unauthorized(err error)

Types

type HTTPError

type HTTPError struct {
	Code      int    `json:"-"`
	Message   any    `json:"message,omitempty"`
	Data      any    `json:"data,omitempty"`
	Developer string `json:"developer_message,omitempty"`
	Internal  error  `json:"-"`
}

func NewHTTPError

func NewHTTPError(code int, err error, message ...any) *HTTPError

func (*HTTPError) Error

func (e *HTTPError) Error() string

func (*HTTPError) Unwrap

func (e *HTTPError) Unwrap() error

type ListResponse

type ListResponse struct {
	Data  any   `json:"data"`
	Total int64 `json:"total"`
	Index int64 `json:"index"`
	Size  int64 `json:"size"`
}

Jump to

Keyboard shortcuts

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