Guest User

Untitled

a guest
Jan 22nd, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. func ServeHTTP(w http.ResponseWriter, r *http.Request) {
  2. w.WriteHeader(http.StatusInternalServerError)
  3. w.Write([]byte("500 - Something bad happened!"))
  4. }
  5.  
  6. func yourFuncHandler(w http.ResponseWriter, r *http.Request) {
  7.  
  8. http.Error(w, "my own error message", http.StatusForbidden)
  9.  
  10. // or using the default message error
  11.  
  12. http.Error(w, http.StatusText(http.StatusNotFound), http.StatusNotFound)
  13. }
  14.  
  15. w.WriteHeader(http.StatusInternalServerError)
  16. w.WriteHeader(http.StatusForbidden)
Add Comment
Please, Sign In to add comment