本文整理了Java中spark.Spark.post()
方法的一些代码示例,展示了Spark.post()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Spark.post()
方法的具体详情如下:
包路径:spark.Spark
类名称:Spark
方法名:post
[英]Map the route for HTTP POST requests
[中]映射HTTP POST请求的路由
代码示例来源:origin: gocd/gocd
@Override
public void setupRoutes() {
path(controllerPath(), () -> {
before("", mimeType, this::setContentType);
before("/*", mimeType, this::setContentType);
before("", this::verifyContentType);
before("/*", this::verifyContentType);
before(Routes.Stage.TRIGGER_STAGE_PATH, mimeType, apiAuthenticationHelper::checkPipelineGroupOperateUserAnd403);
before(Routes.Stage.TRIGGER_FAILED_JOBS_PATH, mimeType, apiAuthenticationHelper::checkPipelineGroupOperateUserAnd403);
before(Routes.Stage.TRIGGER_SELECTED_JOBS_PATH, mimeType, apiAuthenticationHelper::checkPipelineGroupOperateUserAnd403);
before(Routes.Stage.INSTANCE_BY_COUNTER, mimeType, apiAuthenticationHelper::checkPipelineViewPermissionsAnd403);
post(Routes.Stage.TRIGGER_STAGE_PATH, mimeType, this::triggerStage);
post(Routes.Stage.TRIGGER_FAILED_JOBS_PATH, mimeType, this::rerunFailedJobs);
post(Routes.Stage.TRIGGER_SELECTED_JOBS_PATH, mimeType, this::rerunSelectedJobs);
get(Routes.Stage.INSTANCE_BY_COUNTER, mimeType, this::instanceByCounter);
exception(RecordNotFoundException.class, this::notFound);
});
}
代码示例来源:origin: gocd/gocd
@Override
public void setupRoutes() {
path(controllerPath(), () -> {
before("", mimeType, this::setContentType);
before("/*", mimeType, this::setContentType);
before("", this::verifyContentType);
before("/*", this::verifyContentType);
before("/info", mimeType, apiAuthenticationHelper::checkUserAnd403);
before("/start", mimeType, apiAuthenticationHelper::checkUserAnd403);
before("/complete", mimeType, apiAuthenticationHelper::checkUserAnd403);
get("/info", mimeType, this::getUsageStatisticsReporting);
post("/start", mimeType, this::startReporting);
post("/complete", mimeType, this::completeReporting);
});
}
代码示例来源:origin: gocd/gocd
@Override
public void setupRoutes() {
path(controllerPath(), () -> {
before("", mimeType, this::setContentType);
before("/*", mimeType, this::setContentType);
before("", this::verifyContentType);
before("/*", this::verifyContentType);
before(Routes.Pipeline.PAUSE_PATH, mimeType, apiAuthenticationHelper::checkPipelineGroupOperateUserAnd403);
before(Routes.Pipeline.UNPAUSE_PATH, mimeType, apiAuthenticationHelper::checkPipelineGroupOperateUserAnd403);
before(Routes.Pipeline.UNLOCK_PATH, mimeType, apiAuthenticationHelper::checkPipelineGroupOperateUserAnd403);
before(Routes.Pipeline.TRIGGER_OPTIONS_PATH, mimeType, apiAuthenticationHelper::checkPipelineGroupOperateUserAnd403);
before(Routes.Pipeline.SCHEDULE_PATH, mimeType, apiAuthenticationHelper::checkPipelineGroupOperateUserAnd403);
post(Routes.Pipeline.PAUSE_PATH, mimeType, this::pause);
post(Routes.Pipeline.UNPAUSE_PATH, mimeType, this::unpause);
post(Routes.Pipeline.UNLOCK_PATH, mimeType, this::unlock);
get(Routes.Pipeline.TRIGGER_OPTIONS_PATH, mimeType, this::triggerOptions);
post(Routes.Pipeline.SCHEDULE_PATH, mimeType, this::schedule);
exception(RecordNotFoundException.class, this::notFound);
exception(InvalidGoCipherTextRuntimeException.class, (InvalidGoCipherTextRuntimeException exception, Request request, Response response) -> {
response.status(HttpStatus.INTERNAL_SERVER_ERROR.value());
response.body(MessageJson.create(HaltApiMessages.errorWhileEncryptingMessage()));
});
});
}
代码示例来源:origin: gocd/gocd
@Override
public void setupRoutes() {
path(controllerBasePath(), () -> {
before("", mimeType, this::setContentType);
before("/*", mimeType, this::setContentType);
before("", this::verifyContentType);
before("/*", this::verifyContentType);
before(Routes.MaintenanceMode.ENABLE, mimeType, apiAuthenticationHelper::checkAdminUserAnd403);
before(Routes.MaintenanceMode.DISABLE, mimeType, apiAuthenticationHelper::checkAdminUserAnd403);
before(Routes.MaintenanceMode.INFO, mimeType, apiAuthenticationHelper::checkAdminUserAnd403);
post(Routes.MaintenanceMode.ENABLE, mimeType, this::enableMaintenanceModeState);
post(Routes.MaintenanceMode.DISABLE, mimeType, this::disableMaintenanceModeState);
get(Routes.MaintenanceMode.INFO, mimeType, this::getMaintenanceModeInfo);
exception(RecordNotFoundException.class, this::notFound);
});
}
代码示例来源:origin: gocd/gocd
@Override
public void setupRoutes() {
path(controllerBasePath(), () -> {
before("", mimeType, this::setContentType);
before("", mimeType, authenticationHelper::checkAdminUserAnd403);
before("", this::verifyContentType);
before("/*", mimeType, this::setContentType);
before("/*", mimeType, authenticationHelper::checkAdminUserAnd403);
before(PREFLIGHT_PATH, this::setMultipartUpload);
post(PREFLIGHT_PATH, mimeType, this::preflight);
});
}
代码示例来源:origin: gocd/gocd
@Override
public void setupRoutes() {
path(controllerBasePath(), () -> {
before("", mimeType, this::setContentType);
before("/*", mimeType, this::setContentType);
before("", this::verifyConfirmHeader);
before("/*", this::verifyConfirmHeader);
before("", mimeType, apiAuthenticationHelper::checkAdminUserAnd403);
before("/*", mimeType, apiAuthenticationHelper::checkAdminUserAnd403);
post("", mimeType, this::create);
});
}
代码示例来源:origin: gocd/gocd
@Override
public void setupRoutes() {
path(controllerPath(), () -> {
before("", mimeType, this::setContentType);
before("/encrypted", this::setContentType);
before("", this::verifyContentType);
before("/*", this::verifyContentType);
before("", mimeType, apiAuthenticationHelper::checkAdminUserAnd403);
before("/encrypted", mimeType, apiAuthenticationHelper::checkUserAnd403);
get("", mimeType, this::getUsageStatistics);
post("/encrypted", mimeType, this::getEncryptedUsageStatistics);
});
}
代码示例来源:origin: gocd/gocd
@Override
public void setupRoutes() {
path(controllerBasePath(), () -> {
before("", authenticationHelper::checkAdminUserAnd403);
get("", this::index, engine);
});
path(controllerPath(SHOW_PATH), () -> {
before("", this::checkPipelineExists, this::checkPermissions);
before("/*", this::checkPipelineExists, this::checkPermissions);
get("", this::showAnalytics);
post("", this::showAnalytics);
});
}
代码示例来源:origin: gocd/gocd
@Override
public void setupRoutes() {
path(controllerBasePath(), () -> {
before("", mimeType, this::setContentType);
before("/*", mimeType, this::setContentType);
before("", this::verifyContentType);
before("/*", this::verifyContentType);
before("", mimeType, apiAuthenticationHelper::checkAnyAdminUserAnd403);
before("/*", mimeType, apiAuthenticationHelper::checkAnyAdminUserAnd403);
before("", mimeType, this::checkRateLimitAvailable);
post("", mimeType, this::encrypt);
exception(CryptoException.class, (CryptoException exception, Request request, Response response) -> {
response.status(HttpStatus.INTERNAL_SERVER_ERROR.value());
response.body(MessageJson.create(HaltApiMessages.errorWhileEncryptingMessage()));
});
});
}
代码示例来源:origin: gocd/gocd
@Override
public void setupRoutes() {
path(controllerBasePath(), () -> {
before("", this::setContentType);
before("/*", this::setContentType);
before("", mimeType, apiAuthenticationHelper::checkAdminUserAnd403);
before("/*", mimeType, apiAuthenticationHelper::checkAdminUserAnd403);
get("", this::index);
get(Routes.ArtifactStoreConfig.ID, this::show);
post("", this::create);
put(Routes.ArtifactStoreConfig.ID, this::update);
delete(Routes.ArtifactStoreConfig.ID, this::destroy);
exception(RecordNotFoundException.class, this::notFound);
});
}
代码示例来源:origin: gocd/gocd
@Override
public void setupRoutes() {
path(controllerBasePath(), () -> {
before("", this::setContentType);
before("/*", this::setContentType);
before("", mimeType, apiAuthenticationHelper::checkAdminUserOrGroupAdminUserAnd403);
before("/*", mimeType, apiAuthenticationHelper::checkAdminUserOrGroupAdminUserAnd403);
get("", mimeType, this::index);
get(Routes.ElasticProfileAPI.ID, mimeType, this::show);
post("", mimeType, this::create);
put(Routes.ElasticProfileAPI.ID, mimeType, this::update);
delete(Routes.ElasticProfileAPI.ID, mimeType, this::destroy);
exception(RecordNotFoundException.class, this::notFound);
});
}
代码示例来源:origin: gocd/gocd
@Override
public void setupRoutes() {
path(controllerBasePath(), () -> {
before("", mimeType, this::setContentType);
before("", mimeType, authHelper::checkAdminUserAnd403);
before("", this::verifyContentType);
before("/*", mimeType, this::setContentType);
before("/*", mimeType, authHelper::checkAdminUserAnd403);
before("/*", this::verifyContentType);
get(ConfigRepos.INDEX_PATH, mimeType, this::listRepos);
get(ConfigRepos.REPO_PATH, mimeType, this::showRepo);
get(ConfigRepos.STATUS_PATH, mimeType, this::inProgress);
post(ConfigRepos.TRIGGER_UPDATE_PATH, mimeType, this::triggerUpdate);
});
}
代码示例来源:origin: gocd/gocd
@Override
public void setupRoutes() {
path(controllerPath(), () -> {
before("", mimeType, this::setContentType);
before("/*", mimeType, this::setContentType);
before("", this::verifyContentType);
before("/*", this::verifyContentType);
before("", mimeType, apiAuthenticationHelper::checkPipelineCreationAuthorizationAnd403);
before(Routes.PipelineConfig.NAME, mimeType, apiAuthenticationHelper::checkPipelineGroupAdminUserAnd403);
post("", mimeType, this::create);
get(Routes.PipelineConfig.NAME, mimeType, this::show);
put(Routes.PipelineConfig.NAME, mimeType, this::update);
delete(Routes.PipelineConfig.NAME, mimeType, this::destroy);
exception(RecordNotFoundException.class, this::notFound);
});
}
代码示例来源:origin: gocd/gocd
@Override
public void setupRoutes() {
path(controllerBasePath(), () -> {
before("", this::setContentType);
before("/*", this::setContentType);
before("", mimeType, apiAuthenticationHelper::checkAdminUserAnd403);
before("/*", mimeType, apiAuthenticationHelper::checkAdminUserAnd403);
get("", mimeType, this::index);
get(Routes.Environments.NAME, mimeType, this::show);
post("", mimeType, this::create);
put(Routes.Environments.NAME, mimeType, this::update);
patch(Routes.Environments.NAME, this::partialUpdate);
delete(Routes.Environments.NAME, this::remove);
exception(RecordNotFoundException.class, this::notFound);
});
}
代码示例来源:origin: gocd/gocd
@Override
public void setupRoutes() {
path(controllerPath(), () -> {
before("", mimeType, this::setContentType);
before("/*", mimeType, this::setContentType);
before("", this::verifyContentType);
before("/*", this::verifyContentType);
before("", mimeType, apiAuthenticationHelper::checkAdminUserAnd403);
before("/*", mimeType, apiAuthenticationHelper::checkAdminUserAnd403);
get("", mimeType, this::index);
post("", mimeType, this::create);
get(Routes.Roles.NAME_PATH, mimeType, this::show);
put(Routes.Roles.NAME_PATH, mimeType, this::update);
delete(Routes.Roles.NAME_PATH, mimeType, this::destroy);
exception(InvalidPluginTypeException.class, (ex, req, res) -> {
res.body(this.messageJson(ex));
res.status(HttpStatus.BAD_REQUEST.value());
});
exception(RecordNotFoundException.class, this::notFound);
});
}
代码示例来源:origin: gocd/gocd
@Override
public void setupRoutes() {
path(controllerPath(), () -> {
before("", mimeType, this::setContentType);
before("/*", mimeType, this::setContentType);
before("", this::verifyContentType);
before("/*", this::verifyContentType);
before("", mimeType, apiAuthenticationHelper::checkAdminUserAnd403);
before(Routes.PipelineGroupsAdmin.NAME_PATH, mimeType, apiAuthenticationHelper::checkPipelineGroupAdminUserAnd403);
get("", mimeType, this::index);
post("", mimeType, this::create);
get(Routes.PipelineGroupsAdmin.NAME_PATH, mimeType, this::show);
put(Routes.PipelineGroupsAdmin.NAME_PATH, mimeType, this::update);
delete(Routes.PipelineGroupsAdmin.NAME_PATH, mimeType, this::destroy);
exception(RecordNotFoundException.class, this::notFound);
});
}
代码示例来源:origin: gocd/gocd
@Override
public void setupRoutes() {
path(controllerBasePath(), () -> {
before("", mimeType, this::setContentType);
before("", mimeType, authHelper::checkAdminUserAnd403);
before("", this::verifyContentType);
before("/*", mimeType, this::setContentType);
before("/*", mimeType, authHelper::checkAdminUserAnd403);
before("/*", this::verifyContentType);
get(ConfigRepos.INDEX_PATH, mimeType, this::index);
get(ConfigRepos.REPO_PATH, mimeType, this::showRepo);
post(ConfigRepos.CREATE_PATH, mimeType, this::createRepo);
put(ConfigRepos.UPDATE_PATH, mimeType, this::updateRepo);
delete(ConfigRepos.DELETE_PATH, mimeType, this::deleteRepo);
exception(RecordNotFoundException.class, this::notFound);
});
}
代码示例来源:origin: gocd/gocd
@Override
public void setupRoutes() {
path(controllerPath(), () -> {
before("", mimeType, this::setContentType);
before("/*", mimeType, this::setContentType);
before("", this::verifyContentType);
before("/*", this::verifyContentType);
before("", mimeType, apiAuthenticationHelper::checkAdminUserAnd403);
before("/*", mimeType, apiAuthenticationHelper::checkAdminUserAnd403);
get("", mimeType, this::index);
post("", mimeType, this::create);
patch("", mimeType, this::bulkUpdate);
get(Routes.Roles.NAME_PATH, mimeType, this::show);
put(Routes.Roles.NAME_PATH, mimeType, this::update);
delete(Routes.Roles.NAME_PATH, mimeType, this::destroy);
exception(InvalidPluginTypeException.class, (ex, req, res) -> {
res.body(this.messageJson(ex));
res.status(HttpStatus.BAD_REQUEST.value());
});
exception(RecordNotFoundException.class, this::notFound);
});
}
代码示例来源:origin: gocd/gocd
@Override
public void setupRoutes() {
path(controllerBasePath(), () -> {
before("", mimeType, this::setContentType);
before("/*", mimeType, this::setContentType);
before("", this::verifyContentType);
before("/*", this::verifyContentType);
before("", this.mimeType, this.apiAuthenticationHelper::checkAdminUserAnd403);
before("/*", this.mimeType, this.apiAuthenticationHelper::checkAdminUserAnd403);
get("", this.mimeType, this::index);
post("", this.mimeType, this::create);
delete("", this.mimeType, this::bulkDelete);
get(Routes.Users.USER_NAME, this.mimeType, this::show);
patch(Routes.Users.USER_NAME, this.mimeType, this::patchUser);
delete(Routes.Users.USER_NAME, this.mimeType, this::deleteUser);
patch(Routes.Users.USER_STATE, this.mimeType, this::bulkUpdateUsersState);
});
}
代码示例来源:origin: gocd/gocd
@Override
public void setupRoutes() {
path(controllerPath(), () -> {
before("", mimeType, this::setContentType);
before("/*", mimeType, this::setContentType);
before("", this::verifyContentType);
before("/*", this::verifyContentType);
before("", mimeType, onlyOn(apiAuthenticationHelper::checkAdminUserOrGroupAdminUserAnd403, "POST"));
before("", mimeType, onlyOn(apiAuthenticationHelper::checkViewAccessToTemplateAnd403, "GET", "HEAD"));
before(Routes.PipelineTemplateConfig.NAME, mimeType, onlyOn(apiAuthenticationHelper::checkViewAccessToTemplateAnd403, "GET", "HEAD"));
before(Routes.PipelineTemplateConfig.NAME, mimeType, onlyOn(apiAuthenticationHelper::checkAdminOrTemplateAdminAnd403, "PUT", "PATCH", "DELETE"));
get("", mimeType, this::index);
post("", mimeType, this::create);
get(Routes.PipelineTemplateConfig.NAME, mimeType, this::show);
put(Routes.PipelineTemplateConfig.NAME, mimeType, this::update);
delete(Routes.PipelineTemplateConfig.NAME, mimeType, this::destroy);
exception(RecordNotFoundException.class, this::notFound);
});
}
内容来源于网络,如有侵权,请联系作者删除!