func handler(w http.ResponseWriter, r *http.Request) { w.Write([]byte("Hello, world!")) }
func handler(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusNotFound) w.Write([]byte("Page not found")) }
type Person struct { Name string Age int } func handler(w http.ResponseWriter, r *http.Request) { person := Person{"Alice", 30} json, _ := json.Marshal(person) w.Header().Set("Content-Type", "application/json") w.Write(json) }Package library: net/http.