Captain Hook - Web hook server
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.

31 lines
515 B

  1. package main
  2. import (
  3. "log"
  4. "net/http"
  5. )
  6. // Check errors and fail if they're bad
  7. func check(err error) {
  8. if err != nil {
  9. log.Fatal(err)
  10. }
  11. }
  12. // Log weird errors for web stuff
  13. func logError(w http.ResponseWriter, err error) {
  14. if err != nil {
  15. log.Println(err)
  16. writeError(w, errorMessage{
  17. StatusCode: http.StatusInternalServerError,
  18. Msg: err.Error(),
  19. })
  20. }
  21. }
  22. // Check if a value exists and fail if it doesn't
  23. func checkExists(exists bool, msg string) {
  24. if !exists {
  25. log.Fatal(msg)
  26. }
  27. }