vertx.effect.httpclient.HttpClientModule Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of vertx-effect Show documentation
Show all versions of vertx-effect Show documentation
When actors meet Functional Programming
package vertx.effect.httpclient;
import io.vertx.core.http.HttpClientOptions;
import jsonvalues.JsObj;
import vertx.effect.core.AbstractHttpClientModule;
import vertx.effect.λc;
/**
Module that exposes a set of functions to send different requests to a server.
It's created from a {@link HttpClientOptions} instance.
It's just another verticle that needs to be deployed. You can create as many as you want,
with different configurations:
{@code
HttpClientOptions server1Options = new HttpClientOptions();
HttpClientOptions server2Options = new HttpClientOptions();
HttpClientModule httpServer1Module = new HttpClientModule(server1Options);
HttpClientModule httpServer2Module = new HttpClientModule(server2Options);
vertx.deployVerticle(httpServer1Module);
vertx.deployVerticle(httpServer2Module);
}
Once deployed, you can use the defined functions {@link HttpClientModule#get get}, {@link HttpClientModule#post post},
{@link HttpClientModule#put put}, {@link HttpClientModule#delete delete} and so on.
*/
public abstract class HttpClientModule extends AbstractHttpClientModule {
public HttpClientModule(final HttpClientOptions options,
final String address) {
super(options,address);
}
/**
represents a GET request. It takes as input a {@link GetReq} instance and returns a response in a JsObj.
The class {@link HttpResp} contains all the lenses and functions to get info from the response
and manipulate it
*/
public final λc get = (context,builder) -> httpClient.apply(context,builder.createHttpReq());
/**
represents a POST request. It takes as input a {@link PostReq} instance and returns a response in a JsObj.
The class {@link HttpResp} contains all the lenses and functions to get info from the response
and manipulate it
*/
public final λc post = (context,builder) -> httpClient.apply(context,builder.createHttpReq());
/**
represents a PUT request. It takes as input a {@link PutReq} instance and returns a response in a JsObj.
The class {@link HttpResp} contains all the lenses and functions to get info from the response
and manipulate it
*/
public final λc put = (context,builder) -> httpClient.apply(context,builder.createHttpReq());
/**
represents a DELETE request. It takes as input a {@link DeleteReq} instance and returns a response in a JsObj.
The class {@link HttpResp} contains all the lenses and functions to get info from the response
and manipulate it
*/
public final λc delete = (context,builder) -> httpClient.apply(context,builder.createHttpReq());
/**
represents a HEAD request. It takes as input a {@link HeadReq} instance and returns a response in a JsObj.
The class {@link HttpResp} contains all the lenses and functions to get info from the response
and manipulate it
*/
public final λc head = (context,builder) -> httpClient.apply(context,builder.createHttpReq());
/**
represents a OPTIONS request. It takes as input a {@link OptionsReq} instance and returns a response in a JsObj.
The class {@link HttpResp} contains all the lenses and functions to get info from the response
and manipulate it
*/
public final λc options = (context,builder) -> httpClient.apply(context,builder.createHttpReq());
/**
represents a PATCH request. It takes as input a {@link PatchReq} instance and returns a response in a JsObj.
The class {@link HttpResp} contains all the lenses and functions to get info from the response
and manipulate it
*/
public final λc patch = (context,builder) -> httpClient.apply(context,builder.createHttpReq());
/**
represents a TRACE request. It takes as input a {@link TraceReq} instance and returns a response in a JsObj.
The class {@link HttpResp} contains all the lenses and functions to get info from the response
and manipulate it
*/
public final λc trace = (context, builder) -> httpClient.apply(context,builder.createHttpReq());
/**
represents a CONNECT request. It takes as input a {@link ConnectReq} instance and returns a response in a JsObj.
The class {@link HttpResp} contains all the lenses and functions to get info from the response
and manipulate it
*/
public final λc connect = (context,builder) -> httpClient.apply(context,builder.createHttpReq());
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy