// Homework 33, problem 1: Greet from the query string. // // GET /greet?name=Keiko replies with the plain text "Good morning, Keiko." // A missing or empty name replies with status 400 and a short message. // Set the Content-Type to text/plain, because the name comes from the visitor. // // Run with: go run exercises/33/homework/01-greet.go package main import ( "fmt" "net/http" ) func handleGreet(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 /greet", handleGreet) 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) } }