Package ratpack.http

Examples of ratpack.http.HttpMethod


  public MethodHandler(String method) {
    this.method = method.toUpperCase();
  }

  public void handle(Context context) {
    HttpMethod requestMethod = context.getRequest().getMethod();
    if (requestMethod.name(method)) {
      context.next();
    } else if (requestMethod.isOptions()) {
      Response response = context.getResponse();
      response.getHeaders().add(HttpHeaderConstants.ALLOW, method);
      response.status(200).send();
    } else {
      context.clientError(405);
View Full Code Here


    this.handlers = handlers;
  }

  @Override
  public void handle(Context context) throws Exception {
    HttpMethod method = context.getRequest().getMethod();
    if (method.isOptions()) {
      String methods = Joiner.on(",").join(handlers.keySet());
      context.getResponse().getHeaders().add(HttpHeaderConstants.ALLOW, methods);
      context.getResponse().status(200).send();
    } else {
      for (Map.Entry<String, Handler> entry : handlers.entrySet()) {
        String key = entry.getKey();
        if (method.name(key)) {
          entry.getValue().handle(context);
          return;
        }
      }
View Full Code Here

    return context.get(PublicAddress.class).getAddress(context);
  }

  private boolean isFormAvailable() {
    Request request = context.getRequest();
    HttpMethod method = request.getMethod();
    return request.getBody().getContentType().isForm() && (method.isPost() || method.isPut());
  }
View Full Code Here

TOP

Related Classes of ratpack.http.HttpMethod

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.