func helloWorld(w rest.ResponseWriter, r *rest.Request) { response := map[string]string{"message": "Hello, World!"} w.WriteJson(&response) }
func helloUser(w rest.ResponseWriter, r *rest.Request) { user := r.PathParam("user") response := map[string]string{"message": "Hello, " + user + "!"} w.Header().Set("Content-Type", "application/json") w.WriteJson(&response) }This example is similar to the previous one, but we also set the Content-Type header to indicate that the response is a JSON document. This is done using the Header method on the ResponseWriter object.