public class UnirestInstance extends Object implements AutoCloseable
Constructor and Description |
---|
UnirestInstance(Config config)
Create a new UnirestInstance with a config
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Wraps shutdown and will automatically be called when UnirestInstance is
used with try-with-resource.
|
Config |
config()
Access the default configuration for the primary Unirest instance.
|
HttpRequestWithBody |
delete(String url)
Start a DELETE HttpRequest which supports a body from the primary config
|
GetRequest |
get(String url)
Start a GET HttpRequest which does not support a body from the primary config
|
GetRequest |
head(String url)
Start a HEAD HttpRequest which does not support a body from the primary config
|
boolean |
isRunning()
Does the config have currently running clients? Find out here.
|
JsonPatchRequest |
jsonPatch(String url)
Start a PATCH HttpRequest which supports a JSON Patch builder.
|
GetRequest |
options(String url)
Start a OPTIONS HttpRequest which does not support a body from the primary config
|
HttpRequestWithBody |
patch(String url)
Start a PATCH HttpRequest which supports a body from the primary config
|
HttpRequestWithBody |
post(String url)
Start a POST HttpRequest which supports a body from the primary config
|
HttpRequestWithBody |
put(String url)
Start a PUT HttpRequest which supports a body from the primary config
|
HttpRequestWithBody |
request(String method,
String url) |
void |
shutDown()
Close the asynchronous client and its event loop.
|
void |
shutDown(boolean clearOptions)
Close the asynchronous client and its event loop.
|
public UnirestInstance(Config config)
config
- the config for the instancepublic Config config()
public void shutDown()
public void shutDown(boolean clearOptions)
clearOptions
- indicates if options should be cleared. Note that the HttpClient, AsyncClient and thread monitors will not be retained after shutDown.public GetRequest get(String url)
url
- the endpoint to access. Can include placeholders for path params using curly braces {}public GetRequest head(String url)
url
- the endpoint to access. Can include placeholders for path params using curly braces {}public GetRequest options(String url)
url
- the endpoint to access. Can include placeholders for path params using curly braces {}public HttpRequestWithBody post(String url)
url
- the endpoint to access. Can include placeholders for path params using curly braces {}public HttpRequestWithBody delete(String url)
url
- the endpoint to access. Can include placeholders for path params using curly braces {}public HttpRequestWithBody patch(String url)
url
- the endpoint to access. Can include placeholders for path params using curly braces {}public HttpRequestWithBody put(String url)
url
- the endpoint to access. Can include placeholders for path params using curly braces {}public JsonPatchRequest jsonPatch(String url)
url
- the endpoint to access. Can include placeholders for path params using curly braces {}public HttpRequestWithBody request(String method, String url)
public boolean isRunning()
public void close()
close
in interface AutoCloseable
Copyright © 2022. All rights reserved.