use of io.helidon.webserver.ServerRequest in project helidon by oracle.
the class VaultService method deleteSecret.
private void deleteSecret(ServerRequest req, ServerResponse res) {
// has to be for quite a long period of time - did not work with less than 30 days
Instant deleteTime = Instant.now().plus(30, ChronoUnit.DAYS);
vault.deleteSecret(DeleteSecret.Request.builder().secretId(req.path().param("id")).timeOfDeletion(deleteTime)).forSingle(it -> res.status(it.status()).send()).exceptionally(res::send);
}
use of io.helidon.webserver.ServerRequest in project helidon by oracle.
the class MockZipkinService method mockZipkin.
private void mockZipkin(final ServerRequest request, final ServerResponse response) {
request.queryParams().all("serviceName").forEach(s -> System.out.println(">>>" + s));
request.content().registerReader(new MessageBodyStreamReader<JsonValue>() {
@Override
public PredicateResult accept(final GenericType<?> type, final MessageBodyReaderContext context) {
return PredicateResult.COMPATIBLE;
}
@Override
@SuppressWarnings("unchecked")
public <U extends JsonValue> Flow.Publisher<U> read(final Flow.Publisher<DataChunk> publisher, final GenericType<U> type, final MessageBodyReaderContext context) {
return (Flow.Publisher<U>) Multi.create(publisher).map(d -> ByteBuffer.wrap(d.bytes())).reduce((buf, buf2) -> ByteBuffer.allocate(buf.capacity() + buf2.capacity()).put(buf.array()).put(buf2.array())).flatMap(b -> {
try (ByteArrayInputStream bais = new ByteArrayInputStream(b.array());
GZIPInputStream gzipInputStream = new GZIPInputStream(bais)) {
return Single.just(Json.createReader(new StringReader(new String(gzipInputStream.readAllBytes()))).readArray());
} catch (EOFException e) {
// ignore
return Multi.empty();
} catch (IOException e) {
throw new RuntimeException(e);
}
}).flatMap(a -> Multi.create(a.stream()));
}
}).asStream(JsonValue.class).map(JsonValue::asJsonObject).filter(json -> TAGS_POINTER.containsValue(json) && COMPONENT_POINTER.containsValue(json) && filteredComponents.stream().anyMatch(s -> s.equals(((JsonString) COMPONENT_POINTER.getValue(json)).getString()))).onError(Throwable::printStackTrace).onError(t -> response.status(500).send(t)).onComplete(response::send).peek(json -> LOGGER.info(json.toString())).forEach(e -> next.getAndSet(new CompletableFuture<>()).complete(e));
}
use of io.helidon.webserver.ServerRequest in project metro-jax-ws by eclipse-ee4j.
the class HelidonAdapter method addSatellites.
@Override
protected void addSatellites(Packet packet) {
ServerRequest req = (ServerRequest) packet.get(HelidonProperties.REQUEST);
ServerResponse res = (ServerResponse) packet.get(HelidonProperties.RESPONSE);
packet.addSatellite(APISupport.createPropertySet(req, res));
}
Aggregations