These are chat archives for spring-cloud/spring-cloud

29th
Sep 2016
damozhiying
@damozhiying
Sep 29 2016 03:07
how to add ZuulRoute in code and for ui gateway to route
ccit-spence
@ccit-spence
Sep 29 2016 04:50
@625096233 Is this what you mean?
    @RequestMapping(value = "/", method = RequestMethod.GET)
    public String handleRequest() {
        return "forward:/ux/";
    }
damozhiying
@damozhiying
Sep 29 2016 04:59
@ccit-spence
according to the userid add route
@RequestMapping("/reDirect")
public String reDirect(HttpServletRequest request) {
    ZuulRoute route_cy=new ZuulRoute();
    /*route_cy.setId("erp_cy");
    route_cy.setPath("/erp_cy/**");
    route_cy.setUrl("http://169.254.50.169:8081");*/

//    discoveryClientRouteLocator.addRoute(route_cy);



    ZuulRoute route_gwzx=new ZuulRoute();
    route_gwzx.setId("erp_gwzx");
    route_gwzx.setPath("/erp_gwzx/**");
    route_gwzx.setUrl(" http://localhost:9000");

    discoveryClientRouteLocator.addRoute(route_gwzx);

    String id=request.getSession().getId();

    /*URL url = null;
    try {
        url = new URL("http://169.254.50.169:8081");
    } catch (MalformedURLException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    RequestContext.getCurrentContext().setRouteHost(url);*/


    //根据session跳转不同的机器
    return "redirect:/erp_gwzx/";
}
because can't config the route info into yml,it is dynamic ,
ccit-spence
@ccit-spence
Sep 29 2016 05:18
@625096233 Sorry I have never tried that.
(if you want the current request to get forwarded, which it kind of looks like)
damozhiying
@damozhiying
Sep 29 2016 08:44
@dsyer
you are welcome
it probably can't work well
now i extend the ZuulHandlerMapping
first add route
second registerHandlers
Dave Syer
@dsyer
Sep 29 2016 08:50
Whatever works for you (it's not really clear what you need and why)
damozhiying
@damozhiying
Sep 29 2016 10:34
@dsyer i need in code add the route config (that probably is new pc contain the ui and backend services previously we can't know the pc so there no config about this pc in yml )
because the pc config info is dynamic from other system,when user login ,i can get the config info from the session ,so i can get the user belong to which system, last the ui gateway route to the pc which user belong to
David Welch
@dwelch2344
Sep 29 2016 19:55
hey, to get ConfigurationProperties to update when consul changes, do we have to tag them with @RefreshScope? or is it automagic?
Marcos Barbero
@marcosbarbero
Sep 29 2016 19:57
I never used Consul before but if you have some cloud-bus configured the @ConfigurationProperties will be magically updated.
David Welch
@dwelch2344
Sep 29 2016 19:58
nice. imagine it should be the same then. will find out shortly I guess :D
Spencer Gibb
@spencergibb
Sep 29 2016 20:22
@dwelch2344 yes, @ConfigurationProperties don’t need @RefreshScope. They will be updated automatically.
David Welch
@dwelch2344
Sep 29 2016 21:18
woot. thanks
Bill Bauernschmidt
@wbauern
Sep 29 2016 21:23
I need some help overriding the RequestSpecificRetryHandler used by the RibbonLoadBalancingHttpClient. We have a customized version that we had working with the old RestClient but can't figure out how to get it working with the new client in the Camden release. Any tips or examples?