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

12th
Feb 2018
Abhishek Dujari
@abshkd
Feb 12 2018 03:14
if I want to add a forward header to all requests from the gateway matching a certain route, what would be the right way to do this?
Most of these are zuul routes so I dont have a specific controller class
Patricia Guimaraes
@pguimaraes
Feb 12 2018 13:01

Last January 30th, I posted a question about accessing a config server that used a self-signed SSL certifcate. Since then, I have been able to get that to work by following the instructions at http://cloud.spring.io/spring-cloud-static/Edgware.SR1/multi/multi__spring_cloud_config_client.html#custom-rest-template, so I thought I'd post my solution here in case others want to do the same thing. My implementation of a CustomConfigServiceBootstrapConfiguration class can be found at https://github.com/patguimaraes/cloud-native-samples/blob/master/auth-service/src/main/java/sample/authservice/configuration/CustomConfigServiceBootstrapConfiguration.java.

I have a question for the spring-cloud developers though. I originally used the code below to create my custom RestTemplate:

RestTemplateBuilder restTemplateBuilder = new RestTemplateBuilder();
restTemplateBuilder.requestFactory(clientHttpRequestFactory);
RestTemplate restTemplate = restTemplateBuilder.build();

But this code did not cause my custom RestTemplate to be used to access my config server. When I replaced the code above with the line of code below, my custom RestTemplate was used:

RestTemplate restTemplate = new RestTemplate(clientHttpRequestFactory);

Shouldn't both code snippets above produce the same result?

Dave Syer
@dsyer
Feb 12 2018 13:10
Don't know. Neither looks perfect to me. You should be able to @Autowired a RestTemplateBuilder.
Michael Stummvoll
@Stummi
Feb 12 2018 14:10
When I got the Instance of a spring managed @FeignClient interface, is there some easy way to get the actual target url used by this FeignClient?
Dave Syer
@dsyer
Feb 12 2018 14:11
Are you using service discovery?
Marcin Grzejszczak
@marcingrzejszczak
Feb 12 2018 14:11
you can use a load balancer client that will get the URL
Dave Syer
@dsyer
Feb 12 2018 14:11
Or the DiscoveryClient
Michael Stummvoll
@Stummi
Feb 12 2018 14:11
@dsyer not yet, its not sure if it will be used later
Dave Syer
@dsyer
Feb 12 2018 14:12
Then the URL is hardcoded in the annotation attributes?
Michael Stummvoll
@Stummi
Feb 12 2018 14:12
using a property, but yes
Dave Syer
@dsyer
Feb 12 2018 14:13
I guess you can inspect the property then.
What's the question again?
Michael Stummvoll
@Stummi
Feb 12 2018 14:13
hm, right
I managed to do it with some ugly reflective hackery, now I am looking into how to do it less ugly ;)
Dave Syer
@dsyer
Feb 12 2018 14:15
I would just inject the @Value or pull it out of a @ConfigurationProperties. I suppose it depends where you need it.
Michael Stummvoll
@Stummi
Feb 12 2018 14:17
My current (ugly) approach: AopProxyUtils.getSingletonTarget(myFeignInterface), Proxy.getInvocationHandler on the result gives me the actual instance of the protected class FeignInvocationHandler which I can read the target property from with reflection
In a related question: Is there any nice thing to consume Hypermedia-Like apis? I get a document containing hyperlinks (HAL like but not quite that), and I don't see a nice way to use that programatically without a lot of plumbing code
Dave Syer
@dsyer
Feb 12 2018 14:20
There's Traverson in Spring HATEOS. It's a bit thin. But nothing to do with Spring Cloud.
If it's not HAL, it won't help, I guess.
Michael Stummvoll
@Stummi
Feb 12 2018 14:21
well, okay
Nik Gorylenko
@n0mer
Feb 12 2018 18:06
hello everyone
Spencer Gibb
@spencergibb
Feb 12 2018 18:07
hi
are there any plans to update eureka starters to M6?
Nik Gorylenko
@n0mer
Feb 12 2018 18:09
i suspected that starters are renamed
thanks
that clarifies the issue
Kent Johnson
@kentoj
Feb 12 2018 23:00
What would be a good way to enable a Spring Cloud OAuth2 auth server to also be a resource server? I am making a bulk user CSV upload function for my auth server and I want to access control it with the @PreAuthorize() method security.
I have tried using the @EnableResourceServer annotation and have experimented with various @PreAuthorize() attempts. The Authentication is always null when I try to read it. Things works fine on a normal resource server, but on the auth server things do not.