private <T> HttpRequest toRequest(final Resource<? extends T> resource) {
		final var builder = HttpRequest.newBuilder()
			.uri(host.resolve(resource.resolvedPath().substring(1)));

		resource.parameters().stream()
			.filter(p -> p instanceof Parameter.Header)
			.forEach(header -> builder.header(header.key(), header.value()));

		switch (resource.method()) {
			case GET -> builder.GET();
			case POST -> builder.POST(new ClientBodyPublisher(
				writer,
				resource.body().orElse(null)
			));
			case PUT -> builder.PUT(new ClientBodyPublisher(
				writer,
				resource.body().orElse(null)
			));
			case DELETE -> builder.DELETE();
		}

		return builder.build();
	}
Calls the given {@code resource} and returns its result.

@param resource the resource to call
@return the call response
@param <T> the response body type
@throws NullPointerException if the given {@code resource} is {@code null}
jenetics.incubator/src/main/java/io/jenetics/incubator/restful/client/DefaultClient.java