MCPcopy
hub / github.com/OpenTSDB/opentsdb / getAPIMethod

Method getAPIMethod

src/tsd/HttpQuery.java:259–287  ·  view source on GitHub ↗

Determines the requested HttpMethod via VERB and QS override. If the request is a GET and the user provides a valid override method in the method=<method> query string parameter, then the override is returned. If the user supplies an invalid override, an exception is thrown. If

()

Source from the content-addressed store, hash-verified

257 * @since 2.0
258 */
259 public HttpMethod getAPIMethod() {
260 if (this.method() != HttpMethod.GET) {
261 return this.method();
262 } else {
263 if (this.hasQueryStringParam("method_override")) {
264 final String qs_method = this.getQueryStringParam("method_override");
265 if (qs_method == null || qs_method.isEmpty()) {
266 throw new BadRequestException(HttpResponseStatus.METHOD_NOT_ALLOWED,
267 "Missing method override value");
268 }
269 if (qs_method.toLowerCase().equals("get")) {
270 // you can't fix dumb
271 return HttpMethod.GET;
272 } else if (qs_method.toLowerCase().equals("post")){
273 return HttpMethod.POST;
274 } else if (qs_method.toLowerCase().equals("put")){
275 return HttpMethod.PUT;
276 } else if (qs_method.toLowerCase().equals("delete")){
277 return HttpMethod.DELETE;
278 } else {
279 throw new BadRequestException(HttpResponseStatus.METHOD_NOT_ALLOWED,
280 "Unknown or unsupported method override value");
281 }
282 }
283
284 // no override, so just return the method
285 return this.method();
286 }
287 }
288
289 /**
290 * Sets the local serializer based on a query string parameter or content type.

Calls 5

methodMethod · 0.80
isEmptyMethod · 0.80
hasQueryStringParamMethod · 0.45
getQueryStringParamMethod · 0.45
equalsMethod · 0.45