Skip to content

Commit 3a01835

Browse files
committed
Support resolving hastebin api token via environment variable
1 parent cf25fca commit 3a01835

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

web/src/main/java/dev/booky/stackdeobf/web/ApiRoutes.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,19 @@
3636

3737
public final class ApiRoutes {
3838

39-
private static final String HASTEBIN_API_TOKEN = System.getProperty("web.hastebin-api-token");
39+
private static final String HASTEBIN_API_TOKEN;
40+
41+
static {
42+
// try to resolve via system property; if there is no system property to be found,
43+
// try to resolve via environment variable
44+
String tokenProp = System.getProperty("web.hastebin-api-token");
45+
if (tokenProp == null || tokenProp.isBlank()) {
46+
String tokenEnv = System.getenv("HASTEBIN_API_TOKEN");
47+
HASTEBIN_API_TOKEN = tokenEnv == null || tokenEnv.isBlank() ? null : tokenEnv;
48+
} else {
49+
HASTEBIN_API_TOKEN = tokenProp;
50+
}
51+
}
4052

4153
private static final Path CACHE_DIR = Path.of(System.getProperty("mappings.cachedir", "mappings"));
4254
private static final String DEFAULT_MAPPINGS_PROVIDER = "yarn";

0 commit comments

Comments
 (0)