Documentation ¶
Index ¶
- func PanicIfError(err error)
- func Request(method, url string, body []byte, cb func(*http.Response)) error
- func RequestToJSON(req *http.Request, target interface{}) error
- func ResponseJSONToObject(res *http.Response, target interface{}) error
- func ResponseRecorderJSONToObject(res *httptest.ResponseRecorder, target interface{}) error
- func SendBadRequest(w http.ResponseWriter, err error)
- func SendError(w http.ResponseWriter, err error)
- func SendErrorMessage(w http.ResponseWriter, message string)
- func SendImage(w http.ResponseWriter, filename string, contentType string, image []byte)
- func SendOK(w http.ResponseWriter, data interface{})
- func SendOKMessage(w http.ResponseWriter, message string)
- func TimeHelper(v string) time.Time
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Request ¶
Request is a helper which executes a request over the network and returns an error or a response
func RequestToJSON ¶
RequestToJSON converts a Request containing a json object to a targeted interface
func ResponseJSONToObject ¶
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 ¶
TimeHelper converters a string to a time.Time struct.
Types ¶
This section is empty.