Package play.libs.ws.ahc
Class AhcWSClient
java.lang.Object
play.libs.ws.ahc.AhcWSClient
- All Implemented Interfaces:
Closeable,AutoCloseable,WSClient
A WS client backed by AsyncHttpClient implementation.
See https://www.playframework.com/documentation/latest/JavaWS for documentation.
-
Constructor Summary
ConstructorsConstructorDescriptionAhcWSClient(play.libs.ws.ahc.StandaloneAhcWSClient client, Materializer materializer) AhcWSClient(play.shaded.ahc.org.asynchttpclient.AsyncHttpClient client, Materializer materializer) -
Method Summary
Modifier and TypeMethodDescriptionplay.api.libs.ws.WSClientasScala()voidclose()Closes this client, and releases underlying resources.static AhcWSClientcreate(play.api.libs.ws.ahc.AhcWSClientConfig config, play.api.libs.ws.ahc.cache.AhcHttpCache cache, Materializer materializer) Creates WS client manually from configuration, internally creating a new instance of AsyncHttpClient and managing its own thread pool.play.libs.ws.StandaloneWSClientReturn the implementation interface ofStandaloneAhcWSClient.The underlying implementation of the client, if any.Returns a WSRequest object representing the URL.
-
Constructor Details
-
AhcWSClient
public AhcWSClient(play.shaded.ahc.org.asynchttpclient.AsyncHttpClient client, Materializer materializer) -
AhcWSClient
@Inject public AhcWSClient(play.libs.ws.ahc.StandaloneAhcWSClient client, Materializer materializer)
-
-
Method Details
-
create
public static AhcWSClient create(play.api.libs.ws.ahc.AhcWSClientConfig config, play.api.libs.ws.ahc.cache.AhcHttpCache cache, Materializer materializer) Creates WS client manually from configuration, internally creating a new instance of AsyncHttpClient and managing its own thread pool.This client is not managed as part of Play's lifecycle, and must be closed by calling ws.close(), otherwise you will run into memory leaks.
- Parameters:
config- a config object, usually from AhcWSClientConfigFactorycache- if not null, provides HTTP caching.materializer- an Pekko materializer- Returns:
- a new instance of AhcWSClient.
-
getUnderlying
Description copied from interface:WSClientThe underlying implementation of the client, if any. You must cast the returned value to the type you want.- Specified by:
getUnderlyingin interfaceWSClient- Returns:
- the backing object.
-
asScala
public play.api.libs.ws.WSClient asScala() -
url
Description copied from interface:WSClientReturns a WSRequest object representing the URL. You can append additional properties on the WSRequest by chaining calls, and execute the request to return an asynchronousPromise<WSResponse>. -
close
Description copied from interface:WSClientCloses this client, and releases underlying resources.Use this for manually instantiated clients.
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceWSClient- Throws:
IOException
-
getStandaloneWSClient
public play.libs.ws.StandaloneWSClient getStandaloneWSClient()Return the implementation interface ofStandaloneAhcWSClient.- Returns:
StandaloneWSClient
-