Skip to content

Commit

Permalink
feat: allow changing TWIN instance URL on config
Browse files Browse the repository at this point in the history
  • Loading branch information
diogotcorreia committed Jul 14, 2024
1 parent 10f1a09 commit 57dd1b0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ public class MainConfig implements TritonConfig {
private long databaseMysqlPoolConnTimeout;
private Map<String, String> databaseMysqlPoolProperties;
private boolean iKnowWhatIAmDoing;
private String twinInstance;

public MainConfig(Triton<?, ?> main) {
this.main = main;
Expand Down Expand Up @@ -185,6 +186,7 @@ private void setup(Configuration section) {
setupLanguageCreation(languageCreation);

this.iKnowWhatIAmDoing = section.getBoolean("i-know-what-i-am-doing", false);
this.twinInstance = section.getString("twin-instance", "https://twin.rexcantor64.com");
}

public void setup() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ public class TwinManager {
.registerTypeAdapter(LanguageSign.class, new LanguageSignSerializer())
.create();
private static final int TWIN_VERSION = 6;
private static final String BASE_URL = "https://twin.rexcantor64.com";
private final Triton<?, ?> main;

public @NotNull HttpResponse upload(@Nullable List<String> allowedCollections, @Nullable List<String> allowedLanguages) throws NotOnProxyException {
Expand Down Expand Up @@ -123,7 +122,7 @@ public class TwinManager {
}

val encodedData = data.toString();
val u = new URL(BASE_URL + "/api/v1/upload");
val u = new URL(getBaseUrl() + "/api/v1/upload");
val conn = (HttpURLConnection) u.openConnection();
conn.setDoOutput(true);
conn.setRequestMethod("POST");
Expand Down Expand Up @@ -166,7 +165,7 @@ public class TwinManager {
throw new NotOnProxyException();
}
try {
URL u = new URL(BASE_URL + "/api/v1/get/" + id);
URL u = new URL(getBaseUrl() + "/api/v1/get/" + id);
HttpURLConnection conn = (HttpURLConnection) u.openConnection();
conn.setDoOutput(true);
conn.setRequestMethod("GET");
Expand Down Expand Up @@ -200,7 +199,7 @@ public class TwinManager {
}

public static String getBaseUrl() {
return BASE_URL;
return Triton.get().getConfig().getTwinInstance();
}

@RequiredArgsConstructor
Expand Down

0 comments on commit 57dd1b0

Please sign in to comment.