@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); }); }
@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); }); }
@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); }); }
@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); }); }
@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); }); }
@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); }); }
@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); }); }
@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); }); }
@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); }); }
@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); }); }
@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); }); }
@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); }); }
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 "";
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);
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");
@Override public void registry(String path, Route route) { Spark.put(path, route); } },
/** * 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))); }); }
put(getSparkPath(fullPath), this::handle);
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()); }