// Homework 32, problem 3: Status codes. // // Add three routes: // GET /ok replies with 200 and the text "All good." // GET /gone replies with http.NotFound // GET /locked replies with http.Error, the text "Locked." and status 403 // // Check the status of each one with curl.exe -i, as the chapter shows. // // Run with: go run exercises/32/homework/03-status-codes.go package main import ( "fmt" "net/http" ) func handleHome(w http.ResponseWriter, r *http.Request) { fmt.Fprintln(w, "TODO: replace this line") } // TODO: add the three handlers here. func main() { http.HandleFunc("GET /{$}", handleHome) // TODO: add the three routes here. fmt.Println("Server running at http://localhost:8080") fmt.Println("Press Ctrl+C to stop it.") err := http.ListenAndServe("localhost:8080", nil) if err != nil { fmt.Println("Server stopped:", err) } }