本文整理了Java中spark.Spark.put()
方法的一些代码示例,展示了Spark.put()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Spark.put()
方法的具体详情如下:
包路径:spark.Spark
类名称:Spark
方法名:put
[英]Map the route for HTTP PUT requests
[中]映射HTTP PUT请求的路由
代码示例来源:origin: gocd/gocd
@Override
public void setupRoutes() {
path(controllerBasePath(), () -> {
before("", mimeType, this::setContentType);
before("/*", mimeType, this::setContentType);
before("", this::verifyContentType);
before("/*", this::verifyContentType);
get(Routes.PipelineSelection.PIPELINES_DATA, mimeType, this::pipelinesData);
get("", mimeType, this::show);
put("", mimeType, this::update);
});
}
代码示例来源:origin: gocd/gocd
@Override
public void setupRoutes() {
path(controllerPath(), () -> {
before("", mimeType, this::setContentType);
before("/*", mimeType, this::setContentType);
before("", mimeType, this::verifyContentType);
before("/*", mimeType, this::verifyContentType);
before("", mimeType, apiAuthenticationHelper::checkAdminUserAnd403);
before("/*", mimeType, apiAuthenticationHelper::checkAdminUserAnd403);
get("", mimeType, this::show);
put("", mimeType, this::update);
});
}
代码示例来源:origin: gocd/gocd
@Override
public void setupRoutes() {
path(controllerPath(), () -> {
before("", mimeType, this::setContentType);
before("/*", mimeType, this::setContentType);
before("", mimeType, this::verifyContentType);
before("/*", mimeType, this::verifyContentType);
before("", mimeType, apiAuthenticationHelper::checkAdminUserAnd403);
before("/*", mimeType, apiAuthenticationHelper::checkAdminUserAnd403);
get("", mimeType, this::show);
put("", mimeType, this::update);
patch("", mimeType, this::bulkUpdate);
});
}
代码示例来源: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("", 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::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(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(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);
});
}
代码示例来源:origin: bwssytems/ha-bridge
put(SYSTEM_CONTEXT + "/adduser", (request, response) -> {
log.debug("adduser....");
String theDecodedPayload = new String(Base64.getDecoder().decode(request.body()));
put(SYSTEM_CONTEXT + "/deluser", (request, response) -> {
log.debug("deluser....");
String theDecodedPayload = new String(Base64.getDecoder().decode(request.body()));
put(SYSTEM_CONTEXT + "/presslinkbutton", (request, response) -> {
LinkParams linkParams = null;
if(!request.body().isEmpty()) {
put(SYSTEM_CONTEXT + "/logmgmt/update", (request, response) -> {
log.debug("update loggers: " + request.body());
LoggerInfo updateLoggers[];
put(SYSTEM_CONTEXT + "/settings", (request, response) -> {
log.debug("save bridge settings requested from " + request.ip() + " with body: " + request.body());
BridgeSettingsDescriptor newBridgeSettings = new Gson().fromJson(request.body(), BridgeSettingsDescriptor.class);
put(SYSTEM_CONTEXT + "/control/reinit", (request, response) -> {
response.status(HttpStatus.SC_OK);
response.type("application/json");
put(SYSTEM_CONTEXT + "/control/stop", (request, response) -> {
response.status(HttpStatus.SC_OK);
response.type("application/json");
return "";
代码示例来源:origin: bwssytems/ha-bridge
return "";
});
put (API_CONTEXT + "/:id", "application/json", (request, response) -> {
log.debug("Edit a Device - request body: " + request.body());
DeviceDescriptor device = new Gson().fromJson(request.body(), DeviceDescriptor.class);
return "";
});
put (API_CONTEXT + "/backup/create", "application/json", (request, response) -> {
log.debug("Create backup: " + request.body());
BackupFilename aFilename = new Gson().fromJson(request.body(), BackupFilename.class);
代码示例来源:origin: bwssytems/ha-bridge
put(HUE_CONTEXT + "/:userid/groups/:groupid", "application/json", (request, response) -> {
response.header("Access-Control-Allow-Origin", request.headers("Origin"));
response.type("application/json");
put(HUE_CONTEXT + "/:userid/groups/:groupid/action", "application/json", (request, response) -> {
response.header("Access-Control-Allow-Origin", request.headers("Origin"));
response.type("application/json");
put(HUE_CONTEXT + "/:userid/config", "application/json", (request, response) -> {
response.header("Access-Control-Allow-Origin", request.headers("Origin"));
response.type("application/json");
put(HUE_CONTEXT + "/:userid/lights/:id/bridgeupdatestate", "application/json", (request, response) -> {
response.header("Access-Control-Allow-Origin", request.headers("Origin"));
response.type("application/json");
put(HUE_CONTEXT + "/:userid/lights/:id/state", "application/json", (request, response) -> {
response.header("Access-Control-Allow-Origin", request.headers("Origin"));
response.type("application/json");
代码示例来源:origin: com.rapatao.sparkjava/spark-spring-core
@Override
public void registry(String path, Route route) {
Spark.put(path, route);
}
},
代码示例来源:origin: GoogleCloudPlatform/java-docs-samples
/**
* Creates a controller that maps requests to actions.
*/
public UserController(final UserService userService) {
Spark.staticFileLocation("/public");
get("/api/users", (req, res) -> userService.getAllUsers(), json());
get("/api/users/:id", (req, res) -> userService.getUser(req.params(":id")), json());
post("/api/users",
(req, res) -> userService.createUser(req.queryParams("name"), req.queryParams("email")),
json());
put("/api/users/:id", (req, res) -> userService.updateUser(
req.params(":id"),
req.queryParams("name"),
req.queryParams("email")
), json());
delete("/api/users/:id", (req, res) -> userService.deleteUser(req.params(":id")), json());
after((req, res) -> {
res.type("application/json");
});
exception(IllegalArgumentException.class, (error, req, res) -> {
res.status(400);
res.body(toJson(new ResponseError(error)));
});
}
代码示例来源:origin: cagataygurturk/lambadaframework
put(getSparkPath(fullPath), this::handle);
代码示例来源:origin: shekhargulati/todoapp-spark
private void setupEndpoints() {
post(API_CONTEXT + "/todos", "application/json", (request, response) -> {
todoService.createNewTodo(request.body());
response.status(201);
return response;
}, new JsonTransformer());
get(API_CONTEXT + "/todos/:id", "application/json", (request, response)
-> todoService.find(request.params(":id")), new JsonTransformer());
get(API_CONTEXT + "/todos", "application/json", (request, response)
-> todoService.findAll(), new JsonTransformer());
put(API_CONTEXT + "/todos/:id", "application/json", (request, response)
-> todoService.update(request.params(":id"), request.body()), new JsonTransformer());
}
代码示例来源:origin: ikidou/Retrofit2Demo
Spark.put("/blog", BlogHandler.PUT, GsonTransformer.getDefault());
Spark.put("/blog/:id", BlogHandler.PUT, GsonTransformer.getDefault());
内容来源于网络,如有侵权,请联系作者删除!