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> <version>1.0.0</version>
<name>ContaminUS</name> <name>ContaminUS</name>
<properties>
<maven.compiler.source>23</maven.compiler.source>
<maven.compiler.target>23</maven.compiler.target>
</properties>
<dependencies> <dependencies>
<!-- Vert.X Core --> <!-- Vert.X Core -->
<dependency> <dependency>

View File

@@ -1,5 +1,8 @@
package net.miarma.contaminus.server; package net.miarma.contaminus.server;
import java.nio.file.Path;
import java.nio.file.Paths;
import io.vertx.core.AbstractVerticle; import io.vertx.core.AbstractVerticle;
import io.vertx.core.Promise; import io.vertx.core.Promise;
import io.vertx.ext.web.Router; import io.vertx.ext.web.Router;
@@ -19,10 +22,17 @@ public class WebServerVerticle extends AbstractVerticle {
Constants.LOGGER.info("📡 Iniciando WebServerVerticle..."); Constants.LOGGER.info("📡 Iniciando WebServerVerticle...");
Router router = Router.router(vertx); 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("/*") router.route("/*")
.handler( .handler(
StaticHandler.create(configManager.getWebRoot()) StaticHandler.create(webRootPath.toString())
.setCachingEnabled(false) .setCachingEnabled(false)
.setDefaultContentEncoding("UTF-8") .setDefaultContentEncoding("UTF-8")
); );