@Override public void setupRoutes() { path(controllerBasePath(), () -> { before("", this::setContentType); before("/*", this::setContentType); before("", mimeType, this::checkSecurityOr403); before("/*", mimeType, this::checkSecurityOr403); get("", mimeType, this::index); get(Routes.AgentsAPI.UUID, mimeType, this::show); patch(Routes.AgentsAPI.UUID, mimeType, this::update); patch("", mimeType, this::bulkUpdate); delete(Routes.AgentsAPI.UUID, mimeType, this::deleteAgent); delete("", mimeType, this::bulkDeleteAgents); exception(RecordNotFoundException.class, this::notFound); }); }
@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); }); }
@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(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(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::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); }); }
}, new JsonTransformer()); delete (API_CONTEXT + "/:id", "application/json", (request, response) -> { String anId = request.params(":id"); log.debug("Delete a device: " + anId);
@Override public void registry(String path, Route route) { Spark.delete(path, route); } },
delete(HUE_CONTEXT + "/:userid/groups/:groupid", "application/json", (request, response) -> { response.header("Access-Control-Allow-Origin", request.headers("Origin")); response.type("application/json");
/** * 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))); }); }
@Override public void defineEndpoints() { /** * gets all pages as json */ Spark.get("/pages", (req, res) -> getAll(), gson::toJson); /** * add a pages and return the whole list of pages as json */ Spark.post("/pages/add", this::addPage, gson::toJson); /** * Rename a page */ Spark.post("/pages/edit/:id", this::renamePage, gson::toJson); /** * deleete a page and return all as json */ Spark.delete("/page/:id", this::deletePage, gson::toJson); }
delete(getSparkPath(fullPath), this::handle);
break; case DELETE: Spark.delete(path, (req, res) -> processRequest(m, req, res)); break; case PATCH:
public void defineEndpoints() { /* * Add module */ Spark.get("/add-module/on-page/:page", this::addModuleOnPage, new HomeDashTemplateEngine()); /* * Add module with class This will save the module if there are no * settings to display, otherwise it'll show the settings */ Spark.get("/add-module/:pluginclass", this::addModule, new HomeDashTemplateEngine()); /* * Add module */ Spark.get("/module/:moduleId/settings", this::getModuleSettings, new HomeDashTemplateEngine()); /* * Save a new or edited module */ Spark.post("/save-module", this::saveModule, new HomeDashTemplateEngine()); /* * Deletes a module */ Spark.delete("/module/:moduleId", this::deleteModule); /** * Gets the available sizes for a module's plugin */ Spark.get("/module/:id/availableSizes", this::getModuleSizes, gson::toJson); Spark.get("/module/:moduleId/move-to-page/:pageId", this::moveModule, gson::toJson); Spark.get("/module/:moduleId/full-screen", this::getFullScreenView, new HomeDashTemplateEngine()); Spark.post("/module/getNextAvailableSize", this::getNextAvailableSize); }