本文整理了Java中spark.Spark.halt()
方法的一些代码示例,展示了Spark.halt()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Spark.halt()
方法的具体详情如下:
包路径:spark.Spark
类名称:Spark
方法名:halt
[英]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
[中]立即停止筛选器或路由中的请求注意:使用此选项时,不要捕获HaltException类型的异常,或者如果捕获,则重新抛出,否则halt将不起作用
代码示例来源:origin: gocd/gocd
@Override
protected HaltException renderForbiddenResponse() {
return halt(403, HtmlErrorPage.errorPage(403, "Forbidden"));
}
代码示例来源:origin: gocd/gocd
public static HaltException haltBecauseOfReason(String message, Object... tokens) {
return halt(HttpStatus.UNPROCESSABLE_ENTITY.value(), MessageJson.create(format(message, tokens)));
}
}
代码示例来源:origin: gocd/gocd
public static HaltException haltBecauseNotFound(String message, Object... tokens) {
return halt(HttpStatus.NOT_FOUND.value(), MessageJson.create(format(message, tokens)));
}
代码示例来源:origin: gocd/gocd
public static HaltException haltBecauseEtagDoesNotMatch(String message, Object... tokens) {
return halt(HttpStatus.PRECONDITION_FAILED.value(), MessageJson.create(format(message, tokens)));
}
代码示例来源:origin: gocd/gocd
public static HaltException haltBecauseNotFound() {
return halt(HttpStatus.NOT_FOUND.value(), MessageJson.create(notFoundMessage()));
}
代码示例来源:origin: gocd/gocd
public static HaltException haltBecauseEntityAlreadyExists(Consumer<OutputWriter> jsonInRequestBody, String entityType, Object existingName) {
return halt(HttpStatus.UNPROCESSABLE_ENTITY.value(), MessageJson.create(entityAlreadyExistsMessage(entityType, existingName), jsonInRequestBody));
}
代码示例来源:origin: gocd/gocd
public static HaltException haltBecausePropertyIsNotAJsonObject(String property, JsonObject jsonObject) {
return halt(HttpStatus.UNPROCESSABLE_ENTITY.value(), MessageJson.create(propertyIsNotAJsonObject(property, jsonObject)));
}
代码示例来源:origin: gocd/gocd
public static HaltException haltBecauseRequiredParamMissing(String paramName) {
return halt(HttpStatus.BAD_REQUEST.value(), MessageJson.create(missingRequestParameter(paramName)));
}
代码示例来源:origin: gocd/gocd
public static HaltException haltBecauseDeprecatedConfirmHeaderMissing() {
return halt(HttpStatus.BAD_REQUEST.value(), MessageJson.create(deprecatedConfirmHeaderMissing()));
}
代码示例来源:origin: gocd/gocd
public static HaltException haltBecauseMissingJsonProperty(String property, JsonObject jsonObject) {
return halt(HttpStatus.UNPROCESSABLE_ENTITY.value(), MessageJson.create(missingJsonProperty(property, jsonObject)));
}
代码示例来源:origin: gocd/gocd
public static HaltException haltBecauseForbidden() {
return halt(HttpStatus.FORBIDDEN.value(), MessageJson.create(forbiddenMessage()));
}
代码示例来源:origin: gocd/gocd
public static HaltException haltBecauseRateLimitExceeded() {
return halt(HttpStatus.TOO_MANY_REQUESTS.value(), MessageJson.create(rateLimitExceeded()));
}
代码示例来源:origin: gocd/gocd
public static HaltException haltBecauseJsonContentTypeExpected() {
return halt(HttpStatus.UNSUPPORTED_MEDIA_TYPE.value(), MessageJson.create(jsonContentTypeExpected()));
}
代码示例来源:origin: gocd/gocd
public static HaltException haltBecausePropertyIsNotAJsonArray(String property, JsonObject jsonObject) {
return halt(HttpStatus.UNPROCESSABLE_ENTITY.value(), MessageJson.create(propertyIsNotAJsonArray(property, jsonObject)));
}
代码示例来源:origin: gocd/gocd
public static HaltException haltBecauseEtagDoesNotMatch(String entityType, String name) {
return halt(HttpStatus.PRECONDITION_FAILED.value(), MessageJson.create(etagDoesNotMatch(entityType, name)));
}
代码示例来源:origin: gocd/gocd
public static HaltException haltBecauseConfirmHeaderMissing() {
return halt(HttpStatus.BAD_REQUEST.value(), MessageJson.create(confirmHeaderMissing()));
}
代码示例来源:origin: gocd/gocd
public static HaltException haltBecausePropertyIsNotAJsonBoolean(String property, JsonObject jsonObject) {
return halt(HttpStatus.UNPROCESSABLE_ENTITY.value(), MessageJson.create(propertyIsNotAJsonBoolean(property, jsonObject)));
}
代码示例来源:origin: gocd/gocd
public static HaltException haltBecausePropertyIsNotAJsonStringArray(String property, JsonObject jsonObject) {
return halt(HttpStatus.UNPROCESSABLE_ENTITY.value(), MessageJson.create(propertyIsNotAJsonStringArray(property, jsonObject)));
}
代码示例来源:origin: gocd/gocd
private void checkPipelineExists(Request request, Response response) {
if (isPipelineRequest(request)) {
if (null == pipelineConfigService.pipelineConfigNamed(request.queryParams("pipeline_name"))) {
throw halt(404, format("Cannot generate analytics. Pipeline with name: '%s' not found.", request.queryParams("pipeline_name")));
}
}
}
代码示例来源:origin: gocd/gocd
public String showAnalytics(Request request, Response response) {
try {
final AnalyticsData analytics = analyticsExtension.getAnalytics(
request.params(":plugin_id"),
request.params(":type"),
request.params(":id"),
getQueryParams(request));
response.type("application/json");
return GSON.toJson(analytics.toMap());
} catch (Exception e) {
LOG.error("Encountered error while fetching analytics", e);
throw halt(500, format("Error generating analytics from plugin - %s", request.params(":plugin_id")));
}
}
内容来源于网络,如有侵权,请联系作者删除!