1
0

Updated WebServerVerticle

This commit is contained in:
Jose
2025-03-17 11:20:26 +01:00
parent f992c87e3f
commit 42da43af0e
2 changed files with 16 additions and 1 deletions

View File

@@ -5,6 +5,11 @@
<version>1.0.0</version>
<name>ContaminUS</name>
<properties>
<maven.compiler.source>23</maven.compiler.source>
<maven.compiler.target>23</maven.compiler.target>
</properties>
<dependencies>
<!-- Vert.X Core -->
<dependency>

View File

@@ -1,5 +1,8 @@
package net.miarma.contaminus.server;
import java.nio.file.Path;
import java.nio.file.Paths;
import io.vertx.core.AbstractVerticle;
import io.vertx.core.Promise;
import io.vertx.ext.web.Router;
@@ -20,9 +23,16 @@ public class WebServerVerticle extends AbstractVerticle {
Router router = Router.router(vertx);
Path webRootPath = Paths.get(configManager.getWebRoot());
if (webRootPath.isAbsolute()) {
Path basePath = Paths.get(System.getProperty("user.dir")); // Directorio actual
webRootPath = basePath.relativize(webRootPath);
}
router.route("/*")
.handler(
StaticHandler.create(configManager.getWebRoot())
StaticHandler.create(webRootPath.toString())
.setCachingEnabled(false)
.setDefaultContentEncoding("UTF-8")
);