MCPcopy Create free account
hub / github.com/crewjam/saml / HandlePutService

Method HandlePutService

samlidp/service.go:68–92  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

66// HandlePutService handles the `PUT /shortcuts/:id` request. It accepts the XML-formatted
67// service metadata in the request body and stores it.
68func (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.
95func (s *Server) HandleDeleteService(c web.C, w http.ResponseWriter, r *http.Request) {

Callers

nothing calls this directly

Calls 4

getSPMetadataFunction · 0.85
PrintfMethod · 0.80
PutMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected