Class UnirestUtils
java.lang.Object
org.eu.zajc.akiwrapper.core.utils.UnirestUtils
Various utilities regarding Unirest for use with and within Akiwrapper.
- Author:
- Marko Zajc
-
Method Summary
Modifier and TypeMethodDescriptionstatic kong.unirest.UnirestInstanceconfigureInstance(kong.unirest.UnirestInstance unirest) Note: even though this method returns aUnirestInstance, the instance you pass to it is itself mutated and returned.static kong.unirest.UnirestInstanceReturns the singletonUnirestInstanceor creates one if it's null.static voidShuts down the singletonUnirestInstance, if it's present, and does nothing otherwise.
-
Method Details
-
getInstance
@Nonnull public static kong.unirest.UnirestInstance getInstance()Returns the singletonUnirestInstanceor creates one if it's null. Note thatUnirestInstances need to be shut down after they're not needed anymore, so make sure to callshutdownInstance()after you're done with it. Attempting to shut it down manually throughUnirestInstance.shutDown()may cause issues, so don't do that!- Returns:
- the singleton
UnirestInstance
-
shutdownInstance
public static void shutdownInstance()Shuts down the singletonUnirestInstance, if it's present, and does nothing otherwise. Subsequent calls togetInstance()will recreate it. -
configureInstance
@Nonnull public static kong.unirest.UnirestInstance configureInstance(kong.unirest.UnirestInstance unirest) Note: even though this method returns aUnirestInstance, the instance you pass to it is itself mutated and returned. The return value is only there for ease of chaining. Configures a newUnirestInstancefor use by Akiwrapper.
Akinator's API servers are quite picky about the headers you send to them so if you supplyAkiwrapperBuilderwith your ownUnirestInstanceyou should either pass it through this or configure it accordingly yourself.- Parameters:
unirest- theUnirestInstanceto configure- Returns:
- the
UnirestInstanceyou passed, used for chaining
-