use of feign.Target.HardCodedTarget in project feign by OpenFeign.
the class TargetTest method targetCanCreateCustomRequest.
/**
* Per <a href="https://github.com/Netflix/feign/issues/227">#227</a>, some may want to opt out of
* percent encoding. Here's how.
*/
@Test
public void targetCanCreateCustomRequest() throws InterruptedException {
server.enqueue(new MockResponse());
String baseUrl = server.url("/default").toString();
Target<TestQuery> custom = new HardCodedTarget<TestQuery>(TestQuery.class, baseUrl) {
@Override
public Request apply(RequestTemplate input) {
Request urlEncoded = super.apply(input);
return Request.create(urlEncoded.method(), urlEncoded.url().replace("%2F", "/"), urlEncoded.headers(), urlEncoded.body(), urlEncoded.charset());
}
};
Feign.builder().target(custom).get("slash/foo", "slash/bar");
assertThat(server.takeRequest()).hasPath("/default/slash/foo?query=slash/bar");
}
use of feign.Target.HardCodedTarget in project feign by OpenFeign.
the class WhatShouldWeCacheBenchmarks method setup.
@Setup
public void setup() {
feignContract = new Contract.Default();
cachedContact = new Contract() {
private final List<MethodMetadata> cached = new Default().parseAndValidatateMetadata(FeignTestInterface.class);
public List<MethodMetadata> parseAndValidatateMetadata(Class<?> declaring) {
return cached;
}
};
fakeClient = new Client() {
public Response execute(Request request, Request.Options options) throws IOException {
Map<String, Collection<String>> headers = new LinkedHashMap<String, Collection<String>>();
return Response.create(200, "ok", headers, (byte[]) null);
}
};
cachedFakeFeign = Feign.builder().client(fakeClient).build();
cachedFakeApi = cachedFakeFeign.newInstance(new HardCodedTarget<FeignTestInterface>(FeignTestInterface.class, "http://localhost"));
}
Aggregations