HandlePutService handles the `PUT /shortcuts/:id` request. It accepts the XML-formatted service metadata in the request body and stores it.
(c web.C, w http.ResponseWriter, r *http.Request)
| 66 | // HandlePutService handles the `PUT /shortcuts/:id` request. It accepts the XML-formatted |
| 67 | // service metadata in the request body and stores it. |
| 68 | func (s *Server) HandlePutService(c web.C, w http.ResponseWriter, r *http.Request) { |
| 69 | service := Service{} |
| 70 | |
| 71 | metadata, err := getSPMetadata(r.Body) |
| 72 | if err != nil { |
| 73 | s.logger.Printf("ERROR: %s", err) |
| 74 | http.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest) |
| 75 | return |
| 76 | } |
| 77 | |
| 78 | service.Metadata = *metadata |
| 79 | |
| 80 | err = s.Store.Put(fmt.Sprintf("/services/%s", c.URLParams["id"]), &service) |
| 81 | if err != nil { |
| 82 | s.logger.Printf("ERROR: %s", err) |
| 83 | http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError) |
| 84 | return |
| 85 | } |
| 86 | |
| 87 | s.idpConfigMu.Lock() |
| 88 | s.serviceProviders[service.Metadata.EntityID] = &service.Metadata |
| 89 | s.idpConfigMu.Unlock() |
| 90 | |
| 91 | w.WriteHeader(http.StatusNoContent) |
| 92 | } |
| 93 | |
| 94 | // HandleDeleteService handles the `DELETE /services/:id` request. |
| 95 | func (s *Server) HandleDeleteService(c web.C, w http.ResponseWriter, r *http.Request) { |
nothing calls this directly
no test coverage detected