本文整理汇总了Java中org.restlet.routing.Router.setDefaultMatchingMode方法的典型用法代码示例。如果您正苦于以下问题:Java Router.setDefaultMatchingMode方法的具体用法?Java Router.setDefaultMatchingMode怎么用?Java Router.setDefaultMatchingMode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.restlet.routing.Router
的用法示例。
在下文中一共展示了Router.setDefaultMatchingMode方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createInboundRoot
import org.restlet.routing.Router; //导入方法依赖的package包/类
@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;
}
示例2: createInboundRoot
import org.restlet.routing.Router; //导入方法依赖的package包/类
@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;
}
示例3: createInboundRoot
import org.restlet.routing.Router; //导入方法依赖的package包/类
@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);
return router;
}
示例4: createInboundRoot
import org.restlet.routing.Router; //导入方法依赖的package包/类
@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;
}