Updated WebServerVerticle
This commit is contained in:
@@ -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>
|
||||
|
||||
@@ -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")
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user