Merge pull request #8111 from deathbeam/extract-api-vars-to-props
Support specifying API endpoins via java props
This commit is contained in:
@@ -95,23 +95,51 @@ public class RuneLiteAPI
|
|||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static HttpUrl getApiRoot()
|
public static HttpUrl getSessionBase()
|
||||||
{
|
{
|
||||||
return HttpUrl.parse(BASE);
|
final String prop = System.getProperty("runelite.session.url");
|
||||||
|
|
||||||
|
if (prop != null && !prop.isEmpty())
|
||||||
|
{
|
||||||
|
return HttpUrl.parse(prop);
|
||||||
|
}
|
||||||
|
|
||||||
|
return HttpUrl.parse(BASE + "/session");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static HttpUrl getApiBase()
|
public static HttpUrl getApiBase()
|
||||||
{
|
{
|
||||||
|
final String prop = System.getProperty("runelite.http-service.url");
|
||||||
|
|
||||||
|
if (prop != null && !prop.isEmpty())
|
||||||
|
{
|
||||||
|
return HttpUrl.parse(prop);
|
||||||
|
}
|
||||||
|
|
||||||
return HttpUrl.parse(BASE + "/runelite-" + getVersion());
|
return HttpUrl.parse(BASE + "/runelite-" + getVersion());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static HttpUrl getStaticBase()
|
public static HttpUrl getStaticBase()
|
||||||
{
|
{
|
||||||
|
final String prop = System.getProperty("runelite.static.url");
|
||||||
|
|
||||||
|
if (prop != null && !prop.isEmpty())
|
||||||
|
{
|
||||||
|
return HttpUrl.parse(prop);
|
||||||
|
}
|
||||||
|
|
||||||
return HttpUrl.parse(STATICBASE);
|
return HttpUrl.parse(STATICBASE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static HttpUrl getWsEndpoint()
|
public static HttpUrl getWsEndpoint()
|
||||||
{
|
{
|
||||||
|
final String prop = System.getProperty("runelite.ws.url");
|
||||||
|
|
||||||
|
if (prop != null && !prop.isEmpty())
|
||||||
|
{
|
||||||
|
return HttpUrl.parse(prop);
|
||||||
|
}
|
||||||
|
|
||||||
return HttpUrl.parse(WSBASE);
|
return HttpUrl.parse(WSBASE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -39,8 +39,7 @@ class SessionClient
|
|||||||
{
|
{
|
||||||
UUID open() throws IOException
|
UUID open() throws IOException
|
||||||
{
|
{
|
||||||
HttpUrl url = RuneLiteAPI.getApiRoot().newBuilder()
|
HttpUrl url = RuneLiteAPI.getSessionBase().newBuilder()
|
||||||
.addPathSegment("session")
|
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
Request request = new Request.Builder()
|
Request request = new Request.Builder()
|
||||||
@@ -62,8 +61,7 @@ class SessionClient
|
|||||||
|
|
||||||
void ping(UUID uuid) throws IOException
|
void ping(UUID uuid) throws IOException
|
||||||
{
|
{
|
||||||
HttpUrl url = RuneLiteAPI.getApiRoot().newBuilder()
|
HttpUrl url = RuneLiteAPI.getSessionBase().newBuilder()
|
||||||
.addPathSegment("session")
|
|
||||||
.addPathSegment("ping")
|
.addPathSegment("ping")
|
||||||
.addQueryParameter("session", uuid.toString())
|
.addQueryParameter("session", uuid.toString())
|
||||||
.build();
|
.build();
|
||||||
@@ -83,8 +81,7 @@ class SessionClient
|
|||||||
|
|
||||||
void delete(UUID uuid) throws IOException
|
void delete(UUID uuid) throws IOException
|
||||||
{
|
{
|
||||||
HttpUrl url = RuneLiteAPI.getApiRoot().newBuilder()
|
HttpUrl url = RuneLiteAPI.getSessionBase().newBuilder()
|
||||||
.addPathSegment("session")
|
|
||||||
.addQueryParameter("session", uuid.toString())
|
.addQueryParameter("session", uuid.toString())
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user