Skip to content

Commit 05f4117

Browse files
committed
Return Undertow server when calling SimpleServer.start()
1 parent d2a8225 commit 05f4117

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

stubbornjava-common/src/main/java/com/stubbornjava/common/undertow/SimpleServer.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public Undertow.Builder getUndertow() {
2626
return undertowBuilder;
2727
}
2828

29-
public void start() {
29+
public Undertow start() {
3030
Undertow undertow = undertowBuilder.build();
3131
undertow.start();
3232
/*
@@ -37,6 +37,7 @@ public void start() {
3737
undertow.getListenerInfo()
3838
.stream()
3939
.forEach(listenerInfo -> logger.info(listenerInfo.toString()));
40+
return undertow;
4041
}
4142

4243
public static SimpleServer simpleServer(HttpHandler handler) {

stubbornjava-webapp/src/main/java/com/stubbornjava/webapp/StubbornJavaWebApp.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import com.stubbornjava.webapp.post.PostRoutes;
2020
import com.stubbornjava.webapp.themes.ThemeRoutes;
2121

22+
import io.undertow.Undertow;
2223
import io.undertow.server.HttpHandler;
2324
import io.undertow.server.RoutingHandler;
2425
import io.undertow.server.handlers.BlockingHandler;
@@ -90,11 +91,11 @@ private static final HttpHandler getBasicRoutes() {
9091
.setFallbackHandler(timed("notFound", PageRoutes::notFound));
9192
}
9293

93-
private static void startServer() {
94+
private static Undertow startServer() {
9495
HttpHandler staticRoutes = new PathHandler(getBasicRoutes())
9596
.addPrefixPath("/assets", timed("getAssets", CustomHandlers.resource("", (int)TimeUnit.DAYS.toSeconds(30))));
9697
SimpleServer server = SimpleServer.simpleServer(wrapWithMiddleware(staticRoutes));
97-
server.start();
98+
return server.start();
9899
}
99100

100101
public static void main(String[] args) {

0 commit comments

Comments
 (0)