(r *http.Request, refSchema schema.Schema, refExtensions ...schema.Schema)
| 165 | } |
| 166 | |
| 167 | func (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 | } |
no test coverage detected