resourceTypeHandler receives an HTTP GET to retrieve individual resource types which can be returned by appending the resource types name to the /ResourceTypes endpoint. For example: "/ResourceTypes/User".
(w http.ResponseWriter, r *http.Request, name string)
| 178 | // resourceTypeHandler receives an HTTP GET to retrieve individual resource types which can be returned by appending the |
| 179 | // resource types name to the /ResourceTypes endpoint. For example: "/ResourceTypes/User". |
| 180 | func (s Server) resourceTypeHandler(w http.ResponseWriter, r *http.Request, name string) { |
| 181 | var resourceType ResourceType |
| 182 | for _, r := range s.ResourceTypes { |
| 183 | if r.Name == name { |
| 184 | resourceType = r |
| 185 | break |
| 186 | } |
| 187 | } |
| 188 | |
| 189 | if resourceType.Name != name { |
| 190 | scimErr := errors.ScimErrorResourceNotFound(name) |
| 191 | errorHandler(w, r, &scimErr) |
| 192 | return |
| 193 | } |
| 194 | |
| 195 | raw, err := json.Marshal(resourceType.getRaw()) |
| 196 | if err != nil { |
| 197 | errorHandler(w, r, &errors.ScimErrorInternal) |
| 198 | log.Fatalf("failed marshaling resource type: %v", err) |
| 199 | return |
| 200 | } |
| 201 | |
| 202 | _, err = w.Write(raw) |
| 203 | if err != nil { |
| 204 | log.Printf("failed writing response: %v", err) |
| 205 | } |
| 206 | } |
| 207 | |
| 208 | // resourceTypesHandler receives an HTTP GET to this endpoint, "/ResourceTypes", which is used to discover the types of |
| 209 | // resources available on a SCIM service provider (e.g., Users and Groups). Each resource type defines the endpoints, |
no test coverage detected