use of com.spotify.apollo.RequestMetadata in project apollo by spotify.
the class HttpServiceTest method shouldPopulateRequestMetadata.
@Test
public void shouldPopulateRequestMetadata() throws Exception {
AtomicReference<RequestMetadata> metadataReference = new AtomicReference<>();
final InstanceWaiter waiter = new InstanceWaiter();
Future<?> future = executorService.submit(() -> {
try {
HttpService.boot(environment -> environment.routingEngine().registerRoute(Route.async("GET", "/meta", trackMeta(metadataReference))), "metadatatest", waiter);
} catch (LoadingException e) {
throw new RuntimeException(e);
}
});
final Service.Instance instance = waiter.waitForInstance();
Request httpRequest = new Request.Builder().url("http://localhost:29432/meta").build();
new OkHttpClient().newCall(httpRequest).execute();
assertThat(((HttpRequestMetadata) metadataReference.get()).httpVersion(), is("HTTP/1.1"));
instance.getSignaller().signalShutdown();
instance.waitForShutdown();
future.get();
}
use of com.spotify.apollo.RequestMetadata in project apollo by spotify.
the class ApolloRequestHandler method handle.
@Override
public void handle(String target, org.eclipse.jetty.server.Request baseRequest, HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException {
final AsyncContext asyncContext = baseRequest.startAsync();
RequestMetadata metadata = extractMetadata(req);
AsyncContextOngoingRequest ongoingRequest = new AsyncContextOngoingRequest(asApolloRequest(req), asyncContext, logger, metadata);
asyncContext.setTimeout(requestTimeout.toMillis());
asyncContext.addListener(TimeoutListener.create(ongoingRequest));
requestHandler.handle(ongoingRequest);
baseRequest.setHandled(true);
}
Aggregations