Vert.X
This commit is contained in:
20
backend/vertx/src/main/java/net/miarma/contaminus/Main.java
Normal file
20
backend/vertx/src/main/java/net/miarma/contaminus/Main.java
Normal file
@@ -0,0 +1,20 @@
|
||||
package net.miarma.contaminus;
|
||||
import io.vertx.core.AbstractVerticle;
|
||||
import io.vertx.core.Promise;
|
||||
|
||||
public class Main extends AbstractVerticle {
|
||||
|
||||
@Override
|
||||
public void start(Promise<Void> startFuture) {
|
||||
vertx.createHttpServer().requestHandler(r -> {
|
||||
String file = r.path().equals("/") ? "index.html" : r.path().substring(1);
|
||||
r.response().sendFile("webroot/" + file);
|
||||
}).listen(80, result -> {
|
||||
if (result.succeeded()) {
|
||||
startFuture.complete();
|
||||
} else {
|
||||
startFuture.fail(result.cause());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
10
backend/vertx/src/main/resources/webroot/index.html
Normal file
10
backend/vertx/src/main/resources/webroot/index.html
Normal file
@@ -0,0 +1,10 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Vert.X test</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Vert.X test</h1>
|
||||
<p>Hola</p>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user