rest

package
v0.0.0-...-a6acc86 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const MaxBytes = 1048576

Variables

This section is empty.

Functions

func HandleErr

func HandleErr(res http.ResponseWriter, req *http.Request, err error, statusCode ...int)

HandleErr Handles errors and sends a JSON response

func ReadJSON

func ReadJSON(res http.ResponseWriter, req *http.Request, dst interface{}) error

ReadJSON reads the JSON into dst interface obj of the req provided, handlesmost JSON errors

func SendJSON

func SendJSON(res http.ResponseWriter, req *http.Request, dst interface{}, statusCodes ...int) error

SendJSON sends the interface obj as JSON on the res provided

Types

type Response

type Response struct {
	Status int    `json:"status"`
	Msg    string `json:"msg"`
}

func (*Response) Error

func (mr *Response) Error() string

Jump to

Keyboard shortcuts

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