// Homework 33, problem 2: Double from the path. // // GET /double/21 replies with "21 doubled is 42". Use r.PathValue and // strconv.Atoi. A value that is not a whole number, or that is not from // -1000000 to 1000000, replies with status 400. // // Run with: go run exercises/33/homework/02-double.go package main import ( "fmt" "net/http" ) func handleDouble(w http.ResponseWriter, r *http.Request) { // TODO: write your code here, in place of this placeholder line: fmt.Fprintln(w, "TODO: replace this line") } func main() { http.HandleFunc("GET /double/{n}", handleDouble) 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) } }