PLTF-1110: explicit static path

This commit is contained in:
Arkadii Chumachenko 2024-02-16 12:28:14 +00:00
parent 53a6553765
commit 48ffb76a4d
No known key found for this signature in database
GPG key ID: 34B9CA3CCE566874

View file

@ -23,6 +23,9 @@ public class StaticController {
@Value("classpath:static/manifest.json")
private Resource manifestFile;
@Value("#{environment.STATIC_PATH}")
private String staticPath;
private final AtomicReference<String> renderedIndexFile = new AtomicReference<>();
private final AtomicReference<String> renderedManifestFile = new AtomicReference<>();
@ -39,7 +42,11 @@ public class StaticController {
public String getRenderedFile(ServerWebExchange exchange, AtomicReference<String> renderedFile, Resource file) {
String rendered = renderedFile.get();
if (rendered == null) {
rendered = buildFile(file, exchange.getRequest().getPath().contextPath().value());
String contextPath = staticPath;
if (contextPath == null) {
contextPath = exchange.getRequest().getPath().contextPath().value();
}
rendered = buildFile(file, contextPath);
if (renderedFile.compareAndSet(null, rendered)) {
return rendered;
} else {