2019-02-22 03:23:03 +00:00
|
|
|
// Package api contains all the handlers that the client will invoke on the middleware server
|
2019-02-22 03:18:08 +00:00
|
|
|
package api
|
2019-02-27 03:59:30 +00:00
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"fmt"
|
|
|
|
|
"net/http"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// HandleAPIError handles any error that bubbles up to the controller layer
|
|
|
|
|
// TODO: Make the error generic enough with HTTP status codes and messages as well
|
|
|
|
|
func HandleAPIError(w http.ResponseWriter, r *http.Request, err error) {
|
|
|
|
|
// Write content-type, statuscode, payload
|
|
|
|
|
w.Header().Set("Content-Type", "application/json")
|
|
|
|
|
w.WriteHeader(500)
|
|
|
|
|
fmt.Fprintf(w, "%s", err)
|
|
|
|
|
}
|