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

Method parseRequestParams

server.go:167–207  ·  view source on GitHub ↗
(r *http.Request, refSchema schema.Schema, refExtensions ...schema.Schema)

Source from the content-addressed store, hash-verified

165}
166
167func (s Server) parseRequestParams(r *http.Request, refSchema schema.Schema, refExtensions ...schema.Schema) (ListRequestParams, *errors.ScimError) {
168 invalidParams := make([]string, 0)
169
170 defaultCount := s.Config.getItemsPerPage()
171 count, countErr := getIntQueryParam(r, "count", defaultCount)
172 if countErr != nil {
173 invalidParams = append(invalidParams, "count")
174 }
175 if count > defaultCount {
176 // Ensure the count isn't more then the allowable max.
177 count = defaultCount
178 }
179 if count < 0 {
180 // A negative value shall be interpreted as 0.
181 count = 0
182 }
183
184 startIndex, indexErr := getIntQueryParam(r, "startIndex", defaultStartIndex)
185 if indexErr != nil {
186 invalidParams = append(invalidParams, "startIndex")
187 }
188 if startIndex < 1 {
189 startIndex = defaultStartIndex
190 }
191
192 if len(invalidParams) > 0 {
193 scimErr := errors.ScimErrorBadParams(invalidParams)
194 return ListRequestParams{}, &scimErr
195 }
196
197 reqFilter, err := getFilter(r, refSchema, refExtensions...)
198 if err != nil {
199 return ListRequestParams{}, &errors.ScimErrorInvalidFilter
200 }
201
202 return ListRequestParams{
203 Count: count,
204 Filter: reqFilter,
205 StartIndex: startIndex,
206 }, nil
207}

Callers 3

resourceTypesHandlerMethod · 0.95
resourcesGetHandlerMethod · 0.95
schemasHandlerMethod · 0.95

Calls 4

ScimErrorBadParamsFunction · 0.92
getIntQueryParamFunction · 0.85
getFilterFunction · 0.85
getItemsPerPageMethod · 0.80

Tested by

no test coverage detected