PromucFlow_constructor/app/server/src/api/api.go

17 lines
515 B
Go
Raw Normal View History

2019-02-22 03:23:03 +00:00
// Package api contains all the handlers that the client will invoke on the middleware server
package api
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)
}