MCPcopy Create free account
hub / github.com/elimity-com/scim / resourceTypesHandler

Method resourceTypesHandler

handlers.go:211–240  ·  view source on GitHub ↗

resourceTypesHandler receives an HTTP GET to this endpoint, "/ResourceTypes", which is used to discover the types of resources available on a SCIM service provider (e.g., Users and Groups). Each resource type defines the endpoints, the core schema URI that defines the resource, and any supported sc

(w http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

209// resources available on a SCIM service provider (e.g., Users and Groups). Each resource type defines the endpoints,
210// the core schema URI that defines the resource, and any supported schema extensions.
211func (s Server) resourceTypesHandler(w http.ResponseWriter, r *http.Request) {
212 params, paramsErr := s.parseRequestParams(r, schema.ResourceTypeSchema())
213 if paramsErr != nil {
214 errorHandler(w, r, paramsErr)
215 return
216 }
217
218 start, end := clamp(params.StartIndex-1, params.Count, len(s.ResourceTypes))
219 var resources []interface{}
220 for _, v := range s.ResourceTypes[start:end] {
221 resources = append(resources, v.getRaw())
222 }
223
224 raw, err := json.Marshal(listResponse{
225 TotalResults: len(s.ResourceTypes),
226 ItemsPerPage: params.Count,
227 StartIndex: params.StartIndex,
228 Resources: resources,
229 })
230 if err != nil {
231 errorHandler(w, r, &errors.ScimErrorInternal)
232 log.Fatalf("failed marshaling list response: %v", err)
233 return
234 }
235
236 _, err = w.Write(raw)
237 if err != nil {
238 log.Printf("failed writing response: %v", err)
239 }
240}
241
242// resourcesGetHandler receives an HTTP GET request to the resource endpoint, e.g., "/Users" or "/Groups", to retrieve
243// all known resources.

Callers 1

ServeHTTPMethod · 0.95

Calls 5

parseRequestParamsMethod · 0.95
ResourceTypeSchemaFunction · 0.92
errorHandlerFunction · 0.85
clampFunction · 0.85
getRawMethod · 0.45

Tested by

no test coverage detected