Java Code Examples for org.restlet.routing.Router#setDefaultMatchingMode()
The following examples show how to use
org.restlet.routing.Router#setDefaultMatchingMode() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ManagerRestApplication.java From uReplicator with Apache License 2.0 | 6 votes |
@Override public Restlet createInboundRoot() { final Router router = new Router(getContext()); router.setDefaultMatchingMode(Template.MODE_EQUALS); // Topic Servlet router.attach("/topics", TopicManagementRestletResource.class); router.attach("/topics/", TopicManagementRestletResource.class); router.attach("/topics/{topicName}", TopicManagementRestletResource.class); router.attach("/topics/{topicName}/", TopicManagementRestletResource.class); // Admin Servlet router.attach("/admin", AdminRestletResource.class); router.attach("/admin/{opt}", AdminRestletResource.class); // Health Check Servlet router.attach("/health", HealthCheckRestletResource.class); router.attach("/health/", HealthCheckRestletResource.class); return router; }
Example 2
Source File: RestApiServer.java From floodlight_with_topoguard with Apache License 2.0 | 6 votes |
@Override public Restlet createInboundRoot() { Router baseRouter = new Router(context); baseRouter.setDefaultMatchingMode(Template.MODE_STARTS_WITH); for (RestletRoutable rr : restlets) { baseRouter.attach(rr.basePath(), rr.getRestlet(context)); } Filter slashFilter = new Filter() { @Override protected int beforeHandle(Request request, Response response) { Reference ref = request.getResourceRef(); String originalPath = ref.getPath(); if (originalPath.contains("//")) { String newPath = originalPath.replaceAll("/+", "/"); ref.setPath(newPath); } return Filter.CONTINUE; } }; slashFilter.setNext(baseRouter); return slashFilter; }
Example 3
Source File: OntopiaRestApplication.java From ontopia with Apache License 2.0 | 6 votes |
@Override public Restlet createInboundRoot() { // encoding service that allows disabling setEncoderService(new OntopiaEncoderService()); Router versions = new Router(getContext()); versions.setDefaultMatchingMode(Template.MODE_STARTS_WITH); versions.setRoutingMode(Router.MODE_BEST_MATCH); versions.setName("Ontopia API root router"); versions.attach("/", APIInfoResource.class); for (APIVersions version : APIVersions.values()) { if (isEnabled(version)) { logger.info("Exposing API {}", version.getName()); versions.attach("/" + version.getName(), new OntopiaAPIVersionFilter(getContext(), version.createChain(this), version)); } } return versions; }
Example 4
Source File: RestletApplication.java From uReplicator with Apache License 2.0 | 5 votes |
@Override public Restlet createInboundRoot() { final Router router = new Router(getContext()); router.setDefaultMatchingMode(Template.MODE_EQUALS); // Servlet router.attach("/ratelimiter", RateLimiterResource.class); return router; }
Example 5
Source File: ControllerRestApplication.java From uReplicator with Apache License 2.0 | 4 votes |
@Override public Restlet createInboundRoot() { final Router router = new Router(getContext()); router.setDefaultMatchingMode(Template.MODE_EQUALS); // Topic Servlet router.attach("/topics", TopicManagementRestletResource.class); router.attach("/topics/", TopicManagementRestletResource.class); router.attach("/topics/{topicName}", TopicManagementRestletResource.class); router.attach("/topics/{topicName}/", TopicManagementRestletResource.class); // Health Check Servlet router.attach("/health", HealthCheckRestletResource.class); router.attach("/health/", HealthCheckRestletResource.class); // Validation Servlet router.attach("/validation", ValidationRestletResource.class); router.attach("/validation/", ValidationRestletResource.class); router.attach("/validation/{option}", ValidationRestletResource.class); router.attach("/validation/{option}/", ValidationRestletResource.class); // Admin Servlet router.attach("/admin", AdminRestletResource.class); router.attach("/admin/{opt}", AdminRestletResource.class); // MirrorMakerManager Servlet router.attach("/instances", MirrorMakerManagerRestletResource.class); router.attach("/instances/", MirrorMakerManagerRestletResource.class); router.attach("/instances/{instanceName}", MirrorMakerManagerRestletResource.class); router.attach("/instances/{instanceName}/", MirrorMakerManagerRestletResource.class); router.attach("/offset", TopicParitionOffsetRestletResource.class); router.attach("/offset/", TopicParitionOffsetRestletResource.class); router.attach("/offset/{topic}/{partition}", TopicParitionOffsetRestletResource.class); router.attach("/offset/{topic}/{partition}/", TopicParitionOffsetRestletResource.class); router.attach("/noprogress", NoProgressTopicPartitionRestletResource.class); // TopicPartition Blacklist Servlet router.attach("/blacklist", TopicPartitionBlacklistRestletResource.class); return router; }
Example 6
Source File: RestAdminApplication.java From helix with Apache License 2.0 | 4 votes |
@Override public Restlet createInboundRoot() { Router router = new Router(getContext()); router.setDefaultMatchingMode(Template.MODE_EQUALS); router.attach("/clusters", ClustersResource.class); router.attach("/clusters/{clusterName}", ClusterResource.class); router.attach("/clusters/{clusterName}/resourceGroups", ResourceGroupsResource.class); router.attach("/clusters/{clusterName}/resourceGroups/{resourceName}", ResourceGroupResource.class); router.attach("/clusters/{clusterName}/workflows", WorkflowsResource.class); router.attach("/clusters/{clusterName}/jobQueues", JobQueuesResource.class); router.attach("/clusters/{clusterName}/jobQueues/{jobQueue}", JobQueueResource.class); router.attach("/clusters/{clusterName}/jobQueues/{jobQueue}/{job}", JobResource.class); router.attach("/clusters/{clusterName}/instances", InstancesResource.class); router.attach("/clusters/{clusterName}/instances/{instanceName}", InstanceResource.class); router.attach("/clusters/{clusterName}/instances/{instanceName}/currentState/{resourceName}", CurrentStateResource.class); router.attach("/clusters/{clusterName}/instances/{instanceName}/statusUpdate/{resourceName}", StatusUpdateResource.class); router.attach("/clusters/{clusterName}/instances/{instanceName}/errors/{resourceName}", ErrorResource.class); router.attach("/clusters/{clusterName}/instances/{instanceName}/currentState", CurrentStatesResource.class); router.attach("/clusters/{clusterName}/instances/{instanceName}/statusUpdate", StatusUpdatesResource.class); router.attach("/clusters/{clusterName}/instances/{instanceName}/errors", ErrorsResource.class); router.attach("/clusters/{clusterName}/resourceGroups/{resourceName}/idealState", IdealStateResource.class); router.attach("/clusters/{clusterName}/resourceGroups/{resourceName}/externalView", ExternalViewResource.class); router.attach("/clusters/{clusterName}/StateModelDefs/{modelName}", StateModelResource.class); router.attach("/clusters/{clusterName}/StateModelDefs", StateModelsResource.class); router.attach("/clusters/{clusterName}/SchedulerTasks", SchedulerTasksResource.class); router.attach("/clusters/{clusterName}/Controller", ControllerResource.class); router.attach("/clusters/{clusterName}/Controller/statusUpdates/{MessageType}/{MessageId}", ControllerStatusUpdateResource.class); router.attach("/clusters/{clusterName}/configs", ConfigResource.class); router.attach("/clusters/{clusterName}/configs/{scope}", ConfigResource.class); router.attach("/clusters/{clusterName}/configs/{scope}/{scopeKey1}", ConfigResource.class); router.attach("/clusters/{clusterName}/configs/{scope}/{scopeKey1}/{scopeKey2}", ConfigResource.class); router.attach("/clusters/{clusterName}/constraints/{constraintType}", ConstraintResource.class); router.attach("/clusters/{clusterName}/constraints/{constraintType}/{constraintId}", ConstraintResource.class); router.attach("/zkPath", ZkPathResource.class).setMatchingMode(Template.MODE_STARTS_WITH); router.attach("/zkChild", ZkChildResource.class).setMatchingMode(Template.MODE_STARTS_WITH); Restlet mainpage = new Restlet() { @Override public void handle(Request request, Response response) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append("<html>"); stringBuilder.append("<head><title>Restlet Cluster Management page</title></head>"); stringBuilder.append("<body bgcolor=white>"); stringBuilder.append("<table border=\"0\">"); stringBuilder.append("<tr>"); stringBuilder.append("<td>"); stringBuilder.append("<h1>Rest cluster management interface V1</h1>"); stringBuilder.append("</td>"); stringBuilder.append("</tr>"); stringBuilder.append("</table>"); stringBuilder.append("</body>"); stringBuilder.append("</html>"); response.setEntity(new StringRepresentation(stringBuilder.toString(), MediaType.TEXT_HTML)); } }; router.attach("", mainpage); return router; }