Package kong.unirest
Class Unirest
- java.lang.Object
-
- kong.unirest.Unirest
-
public class Unirest extends Object
-
-
Constructor Summary
Constructors Constructor Description Unirest()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Config
config()
Access the default configuration for the primary Unirest instance.static HttpRequestWithBody
delete(String url)
Start a DELETE HttpRequest which supports a body from the primary configstatic GetRequest
get(String url)
Start a GET HttpRequest which does not support a body from the primary configstatic GetRequest
head(String url)
Start a HEAD HttpRequest which does not support a body from the primary configstatic JsonPatchRequest
jsonPatch(String url)
Start a PATCH HttpRequest which supports a JSON Patch builder.static GetRequest
options(String url)
Start a OPTIONS HttpRequest which does not support a body from the primary configstatic HttpRequestWithBody
patch(String url)
Start a PATCH HttpRequest which supports a body from the primary configstatic HttpRequestWithBody
post(String url)
Start a POST HttpRequest which supports a body from the primary configstatic UnirestInstance
primaryInstance()
return the primary UnirestInstance.static HttpRequestWithBody
put(String url)
Start a PUT HttpRequest which supports a body from the primary configstatic HttpRequestWithBody
request(String method, String url)
static void
shutDown()
Close the asynchronous client and its event loop.static void
shutDown(boolean clearOptions)
Close the asynchronous client and its event loop.static UnirestInstance
spawnInstance()
Spawn a new Unirest Instance with a new config.
-
-
-
Method Detail
-
config
public static Config config()
Access the default configuration for the primary Unirest instance.- Returns:
- the config object of the primary instance
-
shutDown
public static void shutDown()
Close the asynchronous client and its event loop. Use this method to close all the threads and allow an application to exit. This will also clear any options returning Unirest to a default state
-
shutDown
public static void shutDown(boolean clearOptions)
Close the asynchronous client and its event loop. Use this method to close all the threads and allow an application to exit.- Parameters:
clearOptions
- indicates if options should be cleared. Note that the HttpClient, AsyncClient and thread monitors will not be retained after shutDown.
-
get
public static GetRequest get(String url)
Start a GET HttpRequest which does not support a body from the primary config- Parameters:
url
- the endpoint to access. Can include placeholders for path params using curly braces {}- Returns:
- A HttpRequest builder
-
head
public static GetRequest head(String url)
Start a HEAD HttpRequest which does not support a body from the primary config- Parameters:
url
- the endpoint to access. Can include placeholders for path params using curly braces {}- Returns:
- A HttpRequest builder
-
options
public static GetRequest options(String url)
Start a OPTIONS HttpRequest which does not support a body from the primary config- Parameters:
url
- the endpoint to access. Can include placeholders for path params using curly braces {}- Returns:
- A HttpRequest builder
-
post
public static HttpRequestWithBody post(String url)
Start a POST HttpRequest which supports a body from the primary config- Parameters:
url
- the endpoint to access. Can include placeholders for path params using curly braces {}- Returns:
- A HttpRequest builder
-
delete
public static HttpRequestWithBody delete(String url)
Start a DELETE HttpRequest which supports a body from the primary config- Parameters:
url
- the endpoint to access. Can include placeholders for path params using curly braces {}- Returns:
- A HttpRequest builder
-
patch
public static HttpRequestWithBody patch(String url)
Start a PATCH HttpRequest which supports a body from the primary config- Parameters:
url
- the endpoint to access. Can include placeholders for path params using curly braces {}- Returns:
- A HttpRequest builder
-
put
public static HttpRequestWithBody put(String url)
Start a PUT HttpRequest which supports a body from the primary config- Parameters:
url
- the endpoint to access. Can include placeholders for path params using curly braces {}- Returns:
- A HttpRequest builder
-
jsonPatch
public static JsonPatchRequest jsonPatch(String url)
Start a PATCH HttpRequest which supports a JSON Patch builder. this supports RFC-6902 https://tools.ietf.org/html/rfc6902- Parameters:
url
- the endpoint to access. Can include placeholders for path params using curly braces {}- Returns:
- A HttpRequest builder
-
request
public static HttpRequestWithBody request(String method, String url)
-
spawnInstance
public static UnirestInstance spawnInstance()
Spawn a new Unirest Instance with a new config. Don't forget to shut it down when your done. It will not be tracked and shutdown with Unirest.shutDown()- Returns:
- a new UnirestInstance
-
primaryInstance
public static UnirestInstance primaryInstance()
return the primary UnirestInstance.- Returns:
- a new UnirestInstance
-
-