mirror of https://github.com/hykilpikonna/AquaDX
[api] Add option to disable aquaviewer serving
parent
19921f4702
commit
3445d073a5
|
@ -19,6 +19,10 @@ billing.server.port=8443
|
|||
## The game rely on 80 port for boot up command
|
||||
server.port=80
|
||||
|
||||
## Static file server
|
||||
## This is used to server static files in /web/ directory, which is Aquaviewer
|
||||
aquaviewer.server.enable=true
|
||||
|
||||
## Chunithm
|
||||
## This enables team function if you set team name here. Leave this blank to disable it.
|
||||
game.chunithm.team-name=
|
||||
|
|
|
@ -2,6 +2,7 @@ package icu.samnyan.aqua.api.config;
|
|||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.io.FileSystemResource;
|
||||
import org.springframework.core.io.Resource;
|
||||
|
@ -12,27 +13,37 @@ import org.springframework.web.servlet.resource.PathResourceResolver;
|
|||
@Configuration
|
||||
public class WebConfig implements WebMvcConfigurer {
|
||||
|
||||
private final boolean AQUAVIEWER_ENABLED;
|
||||
|
||||
public WebConfig(@Value("${aquaviewer.server.enable:true}") boolean AQUAVIEWER_ENABLED) {
|
||||
this.AQUAVIEWER_ENABLED = AQUAVIEWER_ENABLED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
||||
|
||||
// Static assets (images), this priority must be higher than routes
|
||||
registry.addResourceHandler("/web/assets/**")
|
||||
.addResourceLocations("file:web/assets/")
|
||||
.setCachePeriod(10)
|
||||
.resourceChain(true)
|
||||
.addResolver(new PathResourceResolver());
|
||||
if (AQUAVIEWER_ENABLED) {
|
||||
// Static assets (images), this priority must be higher than routes
|
||||
registry.addResourceHandler("/web/assets/**")
|
||||
.addResourceLocations("file:web/assets/")
|
||||
.setCachePeriod(10)
|
||||
.resourceChain(true)
|
||||
.addResolver(new PathResourceResolver());
|
||||
|
||||
// For angularjs html5 routes
|
||||
registry.addResourceHandler("/web/**", "/web/", "/web")
|
||||
.addResourceLocations("file:web/")
|
||||
.setCachePeriod(10)
|
||||
.resourceChain(true)
|
||||
.addResolver(new PathResourceResolver() {
|
||||
@Override
|
||||
protected Resource getResource(String resourcePath, Resource location) throws IOException {
|
||||
Resource requestedResource = location.createRelative(resourcePath);
|
||||
return requestedResource.exists() && requestedResource.isReadable() ? requestedResource : new FileSystemResource("web/index.html");
|
||||
}
|
||||
});
|
||||
// For angularjs html5 routes
|
||||
registry.addResourceHandler("/web/**", "/web/", "/web")
|
||||
.addResourceLocations("file:web/")
|
||||
.setCachePeriod(10)
|
||||
.resourceChain(true)
|
||||
.addResolver(new PathResourceResolver() {
|
||||
@Override
|
||||
protected Resource getResource(String resourcePath, Resource location) throws IOException {
|
||||
Resource requestedResource = location.createRelative(resourcePath);
|
||||
return requestedResource.exists() && requestedResource.isReadable() ? requestedResource
|
||||
: new FileSystemResource("web/index.html");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -29,6 +29,7 @@ public class AutoChecker {
|
|||
private final boolean AIMEDB_ENABLED;
|
||||
private final boolean BILLING_ENABLED;
|
||||
private final int BILLING_PORT;
|
||||
private final boolean AQUAVIEWER_ENABLED;
|
||||
|
||||
public AutoChecker(
|
||||
@Value("${server.host:}") String SERVER_PORT,
|
||||
|
@ -38,7 +39,8 @@ public class AutoChecker {
|
|||
@Value("${aimedb.server.port}") int AIMEDB_PORT,
|
||||
@Value("${aimedb.server.enable}") boolean AIMEDB_ENABLED,
|
||||
@Value("${billing.server.port}") int BILLING_PORT,
|
||||
@Value("${billing.server.enable}") boolean BILLING_ENABLED) {
|
||||
@Value("${billing.server.enable}") boolean BILLING_ENABLED,
|
||||
@Value("${aquaviewer.server.enable:true}") boolean AQUAVIEWER_ENABLED) {
|
||||
this.SERVER_PORT = SERVER_PORT;
|
||||
this.ALLNET_HOST_OVERRIDE = ALLNET_HOST;
|
||||
this.ALLNET_PORT_OVERRIDE = ALLNET_PORT;
|
||||
|
@ -47,6 +49,7 @@ public class AutoChecker {
|
|||
this.AIMEDB_ENABLED = AIMEDB_ENABLED;
|
||||
this.BILLING_PORT = BILLING_PORT;
|
||||
this.BILLING_ENABLED = BILLING_ENABLED;
|
||||
this.AQUAVIEWER_ENABLED = AQUAVIEWER_ENABLED;
|
||||
}
|
||||
|
||||
public void check() {
|
||||
|
@ -59,7 +62,9 @@ public class AutoChecker {
|
|||
"╚═╝ ╚═╝ ╚══▀▀═╝ ╚═════╝ ╚═╝ ╚═╝\n" +
|
||||
" ");
|
||||
|
||||
System.out.println("Aqua viewer at http://localhost/web/\n");
|
||||
if (AQUAVIEWER_ENABLED) {
|
||||
System.out.println("Aqua viewer at http://localhost/web/\n");
|
||||
}
|
||||
|
||||
System.out.println("======= Self test running =======");
|
||||
// Check aimedb
|
||||
|
|
|
@ -7,6 +7,8 @@ aimedb.server.port=22345
|
|||
billing.server.enable=true
|
||||
billing.server.port=8443
|
||||
|
||||
aquaviewer.server.enable=true
|
||||
|
||||
server.port=80
|
||||
|
||||
spring.servlet.multipart.max-file-size=10MB
|
||||
|
|
Loading…
Reference in New Issue