HandleGetService handles the `GET /services/:id` request and responds with the service metadata in XML format.
(c web.C, w http.ResponseWriter, r *http.Request)
| 53 | // HandleGetService handles the `GET /services/:id` request and responds with the service |
| 54 | // metadata in XML format. |
| 55 | func (s *Server) HandleGetService(c web.C, w http.ResponseWriter, r *http.Request) { |
| 56 | service := Service{} |
| 57 | err := s.Store.Get(fmt.Sprintf("/services/%s", c.URLParams["id"]), &service) |
| 58 | if err != nil { |
| 59 | s.logger.Printf("ERROR: %s", err) |
| 60 | http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError) |
| 61 | return |
| 62 | } |
| 63 | xml.NewEncoder(w).Encode(service.Metadata) |
| 64 | } |
| 65 | |
| 66 | // HandlePutService handles the `PUT /shortcuts/:id` request. It accepts the XML-formatted |
| 67 | // service metadata in the request body and stores it. |