Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HTTPWriteImage ¶
func HTTPWriteImage(w http.ResponseWriter, img *image.Image)
HTTPWriteImage utility to write image to response writer
func Logger ¶
// JSON responds to the request with the given code and payload func (app *app) JSON(w http.ResponseWriter, code int, payload interface{}) {
response, _ := json.Marshal(payload) w.Header().Set("Content-Type", "application/json; charset=utf-8") w.Header().Set("Access-Control-Allow-Origin", "*") w.WriteHeader(code) w.Write(response)
}
// JSON responds to the request with the given code and payload
func (app *app) ERROR(w http.ResponseWriter, code int, err error) { response := []byte(err.Error()) w.Header().Set("Content-Type", "application/json; charset=utf-8") w.Header().Set("Access-Control-Allow-Origin", "*") w.WriteHeader(code) w.Write(response) }
Logger function for http calls
Types ¶
type HTTPResponder ¶
type HTTPResponder interface { JSON(w http.ResponseWriter, code int, payload interface{}) ERROR(w http.ResponseWriter, code int, err error) }
HTTPResponder serves method to respond to http calls
Click to show internal directories.
Click to hide internal directories.