• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java RewriteRegexRule类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.eclipse.jetty.rewrite.handler.RewriteRegexRule的典型用法代码示例。如果您正苦于以下问题:Java RewriteRegexRule类的具体用法?Java RewriteRegexRule怎么用?Java RewriteRegexRule使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



RewriteRegexRule类属于org.eclipse.jetty.rewrite.handler包,在下文中一共展示了RewriteRegexRule类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getRewriteHandler

import org.eclipse.jetty.rewrite.handler.RewriteRegexRule; //导入依赖的package包/类
private static Handler getRewriteHandler(Handler wrapped) {
  RewriteHandler rewrites = new RewriteHandler();
  rewrites.setOriginalPathAttribute(ORIGINAL_PATH_ATTRIBUTE_NAME);
  rewrites.setRewriteRequestURI(true);
  rewrites.setRewritePathInfo(true);

  for (Map.Entry<String, String> entry : REGEX_REWRITE_RULES.entrySet()) {
    RewriteRegexRule rule = new RewriteRegexRule();
    rule.setRegex(entry.getKey());
    rule.setReplacement(entry.getValue());
    rewrites.addRule(rule);
  }

  rewrites.setHandler(wrapped);

  return rewrites;
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:18,代码来源:JettyServerModule.java


示例2: configureRedirectionRules

import org.eclipse.jetty.rewrite.handler.RewriteRegexRule; //导入依赖的package包/类
private Handler configureRedirectionRules(Handler appHandler) {
  RewriteHandler handler = new RewriteHandler();
  handler.setRewriteRequestURI(false);
  handler.setRewritePathInfo(false);
  handler.setOriginalPathAttribute("requestedPath");

  RewriteRegexRule uiRewriteRule = new RewriteRegexRule();
  uiRewriteRule.setRegex("^/collector/.*");
  uiRewriteRule.setReplacement("/");
  handler.addRule(uiRewriteRule);
  handler.setHandler(appHandler);

  HandlerCollection handlerCollection = new HandlerCollection();
  handlerCollection.setHandlers(new Handler[] {handler, appHandler});
  return handlerCollection;
}
 
开发者ID:streamsets,项目名称:datacollector,代码行数:17,代码来源:WebServerTask.java


示例3: startWithRewrite

import org.eclipse.jetty.rewrite.handler.RewriteRegexRule; //导入依赖的package包/类
public static Server startWithRewrite(int port) throws Exception {
  Server server = new Server(port);

  ServletContextHandler contextHandler = new ServletContextHandler(ServletContextHandler.SESSIONS);
  contextHandler.setContextPath("/api");
  contextHandler.addServlet(TestServlet.class, "/epigraph/*");

  RewriteHandler rewriteHandler = new RewriteHandler();
  rewriteHandler.addRule(new RewriteRegexRule("(.*?)/getUser/(.*)", "$1/epigraph/users/$2:record(firstName,lastName)"));
  rewriteHandler.setHandler(contextHandler);

  server.setHandler(rewriteHandler);
  server.start();
  return server;
}
 
开发者ID:SumoLogic,项目名称:epigraph,代码行数:16,代码来源:AsyncEpigraphServletHttpServerTest.java


示例4: getRewriteHandler

import org.eclipse.jetty.rewrite.handler.RewriteRegexRule; //导入依赖的package包/类
private Optional<Handler> getRewriteHandler(Handler handler) {
    try {
        String rewriteFilePath = configuration.getRewriteFilePath();
        if (rewriteFilePath != null && !(rewriteFilePath = rewriteFilePath.trim()).isEmpty()) {
            RewriteHandler rewriteHandler = new RewriteHandler();
            rewriteHandler.setRewritePathInfo(false);
            rewriteHandler.setRewriteRequestURI(true);
            rewriteHandler.setOriginalPathAttribute("__path");
            rewriteHandler.setHandler(handler);

            JavaType listRuleType = getMapper().getTypeFactory().constructParametricType(List.class, RewriteRule.class);
            List<RewriteRule> rules = getMapper().readValue(new FileInputStream(rewriteFilePath), listRuleType);
            boolean isAnyRuleActive = false;
            for (RewriteRule rule : rules) {
                if (rule.isActive()) {
                    RewriteRegexRule regexRule = new RewriteRegexRule();
                    regexRule.setRegex(rule.getFrom());
                    regexRule.setReplacement(rule.getTo());
                    rewriteHandler.addRule(regexRule);
                    isAnyRuleActive = true;
                }
            }
            return isAnyRuleActive ? Optional.of(rewriteHandler) : Optional.empty();
        }
    } catch (IOException e) {
        STARTUP_LOGGER.error("Unable to read Rewrite Rules", e);
    }
    return Optional.empty();
}
 
开发者ID:flipkart-incubator,项目名称:Poseidon,代码行数:30,代码来源:Poseidon.java



注:本文中的org.eclipse.jetty.rewrite.handler.RewriteRegexRule类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java SassCompiler类代码示例发布时间:2022-05-22
下一篇:
Java ParameterDirectionKind类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap