util

package
v0.0.0-...-f90f44b Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2018 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PanicIfError

func PanicIfError(err error)

PanicIfError panics when error is not nil

func Request

func Request(method, url string, body []byte, cb func(*http.Response)) error

Request is a helper which executes a request over the network and returns an error or a response

func RequestToJSON

func RequestToJSON(req *http.Request, target interface{}) error

RequestToJSON converts a Request containing a json object to a targeted interface

func ResponseJSONToObject

func ResponseJSONToObject(res *http.Response, target interface{}) error

ResponseJSONToObject converts a Response containing a json object to a targeted interface

func ResponseRecorderJSONToObject

func ResponseRecorderJSONToObject(res *httptest.ResponseRecorder, target interface{}) error

ResponseRecorderJSONToObject converts a ResponseRecorder containing a json to a targeted interface. This is only used in test cases when a httptest server is used.

func SendBadRequest

func SendBadRequest(w http.ResponseWriter, err error)

SendBadRequest writes a Bad Request to the ResponseWrite

func SendError

func SendError(w http.ResponseWriter, err error)

SendError send a http response with status code 400 with the error parameter as error message.

func SendErrorMessage

func SendErrorMessage(w http.ResponseWriter, message string)

SendErrorMessage send a http response an error message

func SendImage

func SendImage(w http.ResponseWriter, filename string, contentType string, image []byte)

SendImage send a http response with a write a image to the client

func SendOK

func SendOK(w http.ResponseWriter, data interface{})

SendOK send http response with header OK and a body interface.

func SendOKMessage

func SendOKMessage(w http.ResponseWriter, message string)

SendOKMessage send http response with header OK and a message.

func TimeHelper

func TimeHelper(v string) time.Time

TimeHelper converters a string to a time.Time struct.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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