/*
 * Copyright (c) 2015-2016, Index Data
 * All rights reserved.
 * See the file LICENSE for details.
 */
package okapi.util;

import io.vertx.core.http.HttpServerResponse;
import io.vertx.ext.web.RoutingContext;

public class HttpResponse {

  static public void responseError(RoutingContext ctx, int code, Throwable cause) {
    responseText(ctx, code).end(cause.getMessage());
  }

  static public HttpServerResponse responseText(RoutingContext ctx, int code) {
    return ctx.response()
            .setStatusCode(code)
            .putHeader("Content-Type", "text/plain");
  }

  static public HttpServerResponse responseJson(RoutingContext ctx, int code) {
    return ctx.response()
            .setStatusCode(code)
            .putHeader("Content-Type", "application/json");
  }
}

@@ -235,16 +235,373 @@
 sponse %7B
+%0A  static public void responseError(RoutingContext ctx, ErrorType t, Throwable cause) %7B%0A    int code = 500;%0A    switch (t) %7B%0A      case OK: code = 200; break;%0A      case INTERNAL: code = 500; break;%0A      case USER: code = 400; break;%0A      case NOT_FOUND: code = 404; break;%0A      case ANY: code = 500; break;%0A    %7D%0A    responseError(ctx, code, cause);%0A  %7D
 %0A%0A  stat

Add responseError: takes ErrorType and maps to HTTP error