HandleDeleteService handles the `DELETE /services/:id` request.
(c web.C, w http.ResponseWriter, r *http.Request)
| 93 | |
| 94 | // HandleDeleteService handles the `DELETE /services/:id` request. |
| 95 | func (s *Server) HandleDeleteService(c web.C, w http.ResponseWriter, r *http.Request) { |
| 96 | service := Service{} |
| 97 | err := s.Store.Get(fmt.Sprintf("/services/%s", c.URLParams["id"]), &service) |
| 98 | if err != nil { |
| 99 | s.logger.Printf("ERROR: %s", err) |
| 100 | http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError) |
| 101 | return |
| 102 | } |
| 103 | |
| 104 | if err := s.Store.Delete(fmt.Sprintf("/services/%s", c.URLParams["id"])); err != nil { |
| 105 | s.logger.Printf("ERROR: %s", err) |
| 106 | http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError) |
| 107 | return |
| 108 | } |
| 109 | |
| 110 | s.idpConfigMu.Lock() |
| 111 | delete(s.serviceProviders, service.Metadata.EntityID) |
| 112 | s.idpConfigMu.Unlock() |
| 113 | |
| 114 | w.WriteHeader(http.StatusNoContent) |
| 115 | } |
| 116 | |
| 117 | // initializeServices reads all the stored services and initializes the underlying |
| 118 | // identity provider to accept them. |