use of jakarta.ws.rs.core.Request in project opentelemetry-java-instrumentation by open-telemetry.
the class JerseySpanName method get.
@Override
@Nullable
public String get(Context context, Request request) {
ContainerRequest containerRequest = (ContainerRequest) request;
UriInfo uriInfo = containerRequest.getUriInfo();
ExtendedUriInfo extendedUriInfo = (ExtendedUriInfo) uriInfo;
return extendedUriInfo.getMatchedTemplates().stream().map((uriTemplate) -> normalizePath(uriTemplate.getTemplate())).reduce((a, b) -> b + a).map(s -> ServletContextPath.prepend(context, JaxrsContextPath.prepend(context, s))).orElse(null);
}
use of jakarta.ws.rs.core.Request in project che-server by eclipse-che.
the class EverrestDownloadFileResponseFilter method doFilter.
/**
* Filter the given container response.
*
* @param containerResponse the response to use
*/
public void doFilter(GenericContainerResponse containerResponse) {
containerResponse.getResponse();
// Get the request
ApplicationContext applicationContext = ApplicationContext.getCurrent();
Request request = applicationContext.getRequest();
// Apply header if all if correct
String filename = getFileName(request, containerResponse.getContentType(), applicationContext, containerResponse.getStatus());
if (filename != null) {
if (hasCompliantEntity(containerResponse.getEntity())) {
// it has been changed, so send response with updated header
Response.ResponseBuilder responseBuilder = Response.fromResponse(containerResponse.getResponse()).header(CONTENT_DISPOSITION, "attachment; filename=" + filename);
containerResponse.setResponse(responseBuilder.build());
}
}
}
use of jakarta.ws.rs.core.Request in project resteasy by resteasy.
the class SynchronousDispatcher method preprocess.
/**
* Call pre-process ContainerRequestFilters.
*
* @param request http request
* @param response http response
* @param continuation runnable
*/
protected void preprocess(HttpRequest request, HttpResponse response, Runnable continuation) {
Response aborted = null;
PreMatchContainerRequestContext requestContext = null;
RESTEasyTracingLogger tracingLogger = RESTEasyTracingLogger.getInstance(request);
try {
final long totalTimestamp = tracingLogger.timestamp("PRE_MATCH_SUMMARY");
for (HttpRequestPreprocessor preprocessor : this.requestPreprocessors) {
final long timestamp = tracingLogger.timestamp("PRE_MATCH");
preprocessor.preProcess(request);
tracingLogger.logDuration("PRE_MATCH", timestamp, preprocessor.getClass().toString());
}
tracingLogger.logDuration("PRE_MATCH_SUMMARY", totalTimestamp, this.requestPreprocessors.size());
ContainerRequestFilter[] requestFilters = providerFactory.getContainerRequestFilterRegistry().preMatch();
requestContext = new PreMatchContainerRequestContext(request, requestFilters, () -> {
continuation.run();
return null;
});
aborted = requestContext.filter();
} catch (Exception e) {
// we only want to catch exceptions happening in the filters, not in the continuation
if (requestContext == null || !requestContext.startedContinuation()) {
writeException(request, response, e, t -> {
});
return;
} else {
rethrow(e);
}
}
if (aborted != null) {
tracingLogger.log("FINISHED", response.getStatus());
tracingLogger.flush(response.getOutputHeaders());
writeResponse(request, response, aborted);
return;
}
}
use of jakarta.ws.rs.core.Request in project resteasy by resteasy.
the class SynchronousDispatcher method invoke.
public void invoke(HttpRequest request, HttpResponse response) {
RESTEasyTracingLogger.initTracingSupport(providerFactory, request);
RESTEasyTracingLogger.logStart(request);
try {
pushContextObjects(request, response);
preprocess(request, response, () -> {
ResourceInvoker invoker = null;
try {
try {
invoker = getInvoker(request);
} catch (Exception exception) {
// logger.error("getInvoker() failed mapping exception", exception);
writeException(request, response, exception, t -> {
});
return;
}
invoke(request, response, invoker);
} finally {
// we're probably clearing it twice but still required
clearContextData();
}
});
} finally {
clearContextData();
}
}
use of jakarta.ws.rs.core.Request in project resteasy by resteasy.
the class SynchronousDispatcher method writeResponse.
protected void writeResponse(HttpRequest request, HttpResponse response, Response jaxrsResponse) {
try {
ServerResponseWriter.writeNomapResponse((BuiltResponse) jaxrsResponse, request, response, providerFactory, t -> {
if (t != null) {
// if we're async we can't trust UnhandledException to be caught
if (request.getAsyncContext().isSuspended() && !request.getAsyncContext().isOnInitialRequest()) {
try {
writeException(request, response, t, t2 -> {
});
} catch (Throwable ex) {
unhandledAsynchronousException(response, ex);
}
} else {
rethrow(t);
}
}
});
} catch (Exception e) {
// logger.error("writeResponse() failed mapping exception", e);
writeException(request, response, e, t -> {
});
} finally {
RESTEasyTracingLogger tracingLogger = RESTEasyTracingLogger.getInstance(request);
tracingLogger.log("FINISHED", response.getStatus());
tracingLogger.flush(response.getOutputHeaders());
}
}
Aggregations