Merge pull request #8111 from deathbeam/extract-api-vars-to-props

Support specifying API endpoins via java props
This commit is contained in:
Adam
2019-05-17 22:49:58 -04:00
committed by GitHub
2 changed files with 33 additions and 8 deletions

View File

@@ -95,23 +95,51 @@ public class RuneLiteAPI
.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()
{
final String prop = System.getProperty("runelite.http-service.url");
if (prop != null && !prop.isEmpty())
{
return HttpUrl.parse(prop);
}
return HttpUrl.parse(BASE + "/runelite-" + getVersion());
}
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);
}
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);
}

View File

@@ -39,8 +39,7 @@ class SessionClient
{
UUID open() throws IOException
{
HttpUrl url = RuneLiteAPI.getApiRoot().newBuilder()
.addPathSegment("session")
HttpUrl url = RuneLiteAPI.getSessionBase().newBuilder()
.build();
Request request = new Request.Builder()
@@ -62,8 +61,7 @@ class SessionClient
void ping(UUID uuid) throws IOException
{
HttpUrl url = RuneLiteAPI.getApiRoot().newBuilder()
.addPathSegment("session")
HttpUrl url = RuneLiteAPI.getSessionBase().newBuilder()
.addPathSegment("ping")
.addQueryParameter("session", uuid.toString())
.build();
@@ -83,8 +81,7 @@ class SessionClient
void delete(UUID uuid) throws IOException
{
HttpUrl url = RuneLiteAPI.getApiRoot().newBuilder()
.addPathSegment("session")
HttpUrl url = RuneLiteAPI.getSessionBase().newBuilder()
.addQueryParameter("session", uuid.toString())
.build();