Micro-service for file storage and processing written in Go
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

17 lines
345 B

  1. package controllers
  2. import (
  3. "encoding/json"
  4. "github.com/sirupsen/logrus"
  5. "net/http"
  6. )
  7. func writeError(w http.ResponseWriter, status int, errStr string) {
  8. w.WriteHeader(status)
  9. err := json.NewEncoder(w).Encode(struct {
  10. Error string `json:"error"`
  11. }{errStr})
  12. if err != nil {
  13. logrus.Fatal("Could not write JSON response: ", err)
  14. }
  15. }