"Resource identifier") err := params.Parse(r.Form) if err != nil { // Do something with the err } // Make sure we have a valid resource ID. if *resourceID == -1 { // Handle the invalid resource }
// context into a structured response. func responseGenerator(c siesta.Context, w http.ResponseWriter, r *http.Request) { response := apiResponse{} if data := c.Get("data"); data != nil { response.Data = data } if err := c.Get("error"); err != nil { response.Error = err.(string) } c.Set("response", response) }