2020-12-05

hi-nginx-java的无配置路由配置

hi-nginx-java既可以通过实现hi.servlet抽象来像Flask那样快速配置路由,例如:

1 hi.route r = hi.route.get_instance();2 r.get("^/(hello|test)/?$", this::do_hello);

也能绕过hi.servlet抽象实现无配置路由配置,即通过实现hi.route.run_t抽象直奔业务逻辑而去,例如:

 1 package hi; 2  3 import hi.request; 4 import hi.response; 5 import hi.route; 6 import java.util.regex.Matcher; 7  8 public class helloworld implements hi.route.run_t { 9  public helloworld() {10  }11 12  public void handler(hi.request req, hi.response res, Matcher m) {13   res.set_content_type("text/plain;charset=utf-8");14   res.content = "hello,world\n";15   res.status = 200;16  }17 }

要调用hi.helloworld类,只需在hi-nginx中配置hi-nginx-java自带的默认控制器hi.controller即可:

location ~ \.java { rewrite ^/(.*)\.java$ /$1 break; hi_java_servlet hi/controller;}

如此,访 />






原文转载:http://www.shaoqun.com/a/494935.html

krazy:https://www.ikjzd.com/w/1801

白色清关:https://www.ikjzd.com/w/1410

usps国际快递查询:https://www.ikjzd.com/w/513


hi-nginx-java既可以通过实现hi.servlet抽象来像Flask那样快速配置路由,例如:1hi.router=hi.route.get_instance();2r.get("^/(hello|test)/?$",this::do_hello);也能绕过hi.servlet抽象实现无配置路由配置,即通过实现hi.route.run_t抽象直奔业务逻辑而去,例如:1p
google correlate:google correlate
吴佳:吴佳
观澜生态水上乐园地铁坐几号线?深圳观澜水上乐园坐地铁去方便:观澜生态水上乐园地铁坐几号线?深圳观澜水上乐园坐地铁去方便
厦门小坪森林公园有什么好玩的?:厦门小坪森林公园有什么好玩的?
峨眉山--香橙 - :峨眉山--香橙 -

No comments:

Post a Comment