httputils

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2021 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeBody

func DecodeBody(w http.ResponseWriter, body io.ReadCloser, v interface{}) error

DecodeBody decodes a JSON body or write/return an error if an error occurs

func ErrorOut

func ErrorOut(w http.ResponseWriter, code int, msg string)

ErrorOut outputs an error

func JSONOut

func JSONOut(w http.ResponseWriter, statusCode int, v interface{}) error

JSONOut outputs the given data structure to JSON

Types

type OutputResponse

type OutputResponse struct {
	Error  bool   `json:"error,omitempty"`
	Status string `json:"status"`
}

OutputResponse is a generic output response

func StatusError

func StatusError(status string) *OutputResponse

StatusError Return an error status response

func StatusOk

func StatusOk(status string) *OutputResponse

StatusOk Return an ok status response

Jump to

Keyboard shortcuts

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