mirror of https://github.com/hykilpikonna/AquaDX
[api] Add internal aquaviewer serving feature
parent
27ff23c662
commit
068081be1f
|
@ -0,0 +1,38 @@
|
|||
package icu.samnyan.aqua.api.config;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.io.FileSystemResource;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
import org.springframework.web.servlet.resource.PathResourceResolver;
|
||||
|
||||
@Configuration
|
||||
public class WebConfig implements WebMvcConfigurer {
|
||||
|
||||
@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());
|
||||
|
||||
// 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");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
|
@ -19,6 +19,7 @@ import java.time.LocalDateTime;
|
|||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import static icu.samnyan.aqua.sega.util.AquaConst.DEFAULT_KEYCHIP_ID;
|
||||
|
||||
|
@ -41,8 +42,8 @@ public class AllNetController {
|
|||
}
|
||||
|
||||
@GetMapping("/")
|
||||
public String root() {
|
||||
return "Server running";
|
||||
public void root(HttpServletResponse response) throws IOException {
|
||||
response.sendRedirect("web");
|
||||
}
|
||||
|
||||
@GetMapping("/sys/test")
|
||||
|
|
|
@ -59,6 +59,8 @@ public class AutoChecker {
|
|||
"╚═╝ ╚═╝ ╚══▀▀═╝ ╚═════╝ ╚═╝ ╚═╝\n" +
|
||||
" ");
|
||||
|
||||
System.out.println("Aqua viewer at http://localhost/web/\n");
|
||||
|
||||
System.out.println("======= Self test running =======");
|
||||
// Check aimedb
|
||||
System.out.print(" AimeDB : ");
|
||||
|
|
Loading…
Reference in New Issue