use of io.helidon.webserver.ServerRequest in project helidon by oracle.
the class OutboundOverrideExample method propagate.
private static void propagate(ServerRequest req, ServerResponse res) {
SecurityContext context = getSecurityContext(req);
webTarget(servingPort).request(String.class).thenAccept(result -> res.send("You are: " + context.userName() + ", backend service returned: " + result + "\n")).exceptionally(throwable -> sendError(throwable, res));
}
use of io.helidon.webserver.ServerRequest in project helidon by oracle.
the class OutboundOverrideJwtExample method propagate.
private static void propagate(ServerRequest req, ServerResponse res) {
SecurityContext context = getSecurityContext(req);
webTarget(servingPort).request(String.class).thenAccept(result -> res.send("You are: " + context.userName() + ", backend service returned: " + result)).exceptionally(throwable -> sendError(throwable, res));
}
use of io.helidon.webserver.ServerRequest in project helidon by oracle.
the class OutboundOverrideJwtExample method override.
private static void override(ServerRequest req, ServerResponse res) {
SecurityContext context = getSecurityContext(req);
webTarget(servingPort).property(JwtProvider.EP_PROPERTY_OUTBOUND_USER, "jill").request(String.class).thenAccept(result -> res.send("You are: " + context.userName() + ", backend service returned: " + result)).exceptionally(throwable -> sendError(throwable, res));
}
use of io.helidon.webserver.ServerRequest in project helidon by oracle.
the class ObjectStorageService method upload.
private void upload(ServerRequest req, ServerResponse res) {
OptionalLong contentLength = req.headers().contentLength();
if (contentLength.isEmpty()) {
req.content().forEach(DataChunk::release);
res.status(Http.Status.BAD_REQUEST_400).send("Content length must be defined");
return;
}
String objectName = req.path().param("file-name");
PutObject.Request request = PutObject.Request.builder().objectName(objectName).bucket(bucketName).contentLength(contentLength.getAsLong());
req.headers().contentType().ifPresent(request::requestMediaType);
objectStorage.putObject(request, req.content()).forSingle(response -> res.send(response.requestId())).exceptionally(res::send);
}
use of io.helidon.webserver.ServerRequest in project helidon by oracle.
the class MpTracingContextFilter method filter.
@Override
public void filter(ContainerRequestContext requestContext) {
ServerRequest serverRequest = this.request.get();
Tracer tracer = serverRequest.tracer();
Optional<SpanContext> parentSpan = serverRequest.spanContext();
boolean clientEnabled = config.getOptionalValue("tracing.client.enabled", Boolean.class).orElse(true);
TracingContext tracingContext = TracingContext.create(tracer, serverRequest.headers().toMap(), clientEnabled);
parentSpan.ifPresent(tracingContext::parentSpan);
Contexts.context().ifPresent(ctx -> ctx.register(tracingContext));
}
Aggregations