/** * Immediately stops a request within a filter or route with specified status code and body content * NOTE: When using this don't catch exceptions of type HaltException, or if catched, re-throw otherwise * halt will not work * * @param status The status code * @param body The body content */ public static HaltException halt(int status, String body) { throw getInstance().halt(status, body); }
/** * Immediately stops a request within a filter or route with specified status code * NOTE: When using this don't catch exceptions of type HaltException, or if catched, re-throw otherwise * halt will not work * * @param status the status code */ public static HaltException halt(int status) { throw getInstance().halt(status); }
/** * Immediately stops a request within a filter or route * NOTE: When using this don't catch exceptions of type HaltException, or if catched, re-throw otherwise * halt will not work */ public static HaltException halt() { throw getInstance().halt(); }
/** * Immediately stops a request within a filter or route with specified body content * NOTE: When using this don't catch exceptions of type HaltException, or if catched, re-throw otherwise * halt will not work * * @param body The body content */ public static HaltException halt(String body) { throw getInstance().halt(body); }
/** * Immediately stops a request within a filter or route with specified status code * NOTE: When using this don't catch exceptions of type HaltException, or if catched, re-throw otherwise * halt will not work * * @param status the status code */ public static HaltException halt(int status) { throw getInstance().halt(status); }
/** * Immediately stops a request within a filter or route with specified body content * NOTE: When using this don't catch exceptions of type HaltException, or if catched, re-throw otherwise * halt will not work * * @param body The body content */ public static HaltException halt(String body) { throw getInstance().halt(body); }
/** * Immediately stops a request within a filter or route with specified status code and body content * NOTE: When using this don't catch exceptions of type HaltException, or if catched, re-throw otherwise * halt will not work * * @param status The status code * @param body The body content */ public static HaltException halt(int status, String body) { throw getInstance().halt(status, body); }
/** * Immediately stop the request. * @param code the HTTP action status code * @param body the HTTP action response body */ protected void stop(int code, String body) { if (service == null) { Spark.halt(code, body); } else { service.halt(code, body); } }
/** * Immediately stops a request within a filter or route * NOTE: When using this don't catch exceptions of type HaltException, or if catched, re-throw otherwise * halt will not work */ public static HaltException halt() { throw getInstance().halt(); }
@Override public void handle(final Request request, final Response response) { if (!isAuthenticated(request.headers("Authorization"))) { response.header("WWW-Authenticate", "Basic"); server.halt(UNAUTHORIZED_STATUS_CODE); } }
service.halt(403, "Not authenticated.");