~kota/granola

d134f8c63ce51ae2a3b387da1e7c7dfef247c3fd — Dakota Walsh 4 months ago 39f5523 main
Change 405 to http.StatusMethodNotAllowed

It's a good habit to use these constants instead of trying to remember
all the http status codes (or having to look them up...)
1 files changed, 4 insertions(+), 4 deletions(-)

M cmd/granola/handlers.go
M cmd/granola/handlers.go => cmd/granola/handlers.go +4 -4
@@ 36,7 36,7 @@ func (g *granola) home(w http.ResponseWriter, r *http.Request) {
func (g *granola) newUser(w http.ResponseWriter, r *http.Request) {
	if r.Method != "POST" {
		w.Header().Set("Allow", "POST")
		http.Error(w, "Method Not Allowed", 405)
		http.Error(w, "Method Not Allowed", http.StatusMethodNotAllowed)
		return
	}



@@ 46,7 46,7 @@ func (g *granola) newUser(w http.ResponseWriter, r *http.Request) {
func (g *granola) newBook(w http.ResponseWriter, r *http.Request) {
	if r.Method != "POST" {
		w.Header().Set("Allow", "POST")
		http.Error(w, "Method Not Allowed", 405)
		http.Error(w, "Method Not Allowed", http.StatusMethodNotAllowed)
		return
	}



@@ 56,7 56,7 @@ func (g *granola) newBook(w http.ResponseWriter, r *http.Request) {
func (g *granola) newClub(w http.ResponseWriter, r *http.Request) {
	if r.Method != "POST" {
		w.Header().Set("Allow", "POST")
		http.Error(w, "Method Not Allowed", 405)
		http.Error(w, "Method Not Allowed", http.StatusMethodNotAllowed)
		return
	}



@@ 66,7 66,7 @@ func (g *granola) newClub(w http.ResponseWriter, r *http.Request) {
func (g *granola) newPost(w http.ResponseWriter, r *http.Request) {
	if r.Method != "POST" {
		w.Header().Set("Allow", "POST")
		http.Error(w, "Method Not Allowed", 405)
		http.Error(w, "Method Not Allowed", http.StatusMethodNotAllowed)
		return
	}