Skip to content

Commit 7360003

Browse files
committed
Expose undertow builder not server
1 parent 65f5964 commit 7360003

2 files changed

Lines changed: 8 additions & 8 deletions

File tree

  • stubbornjava-common/src/main/java/com/stubbornjava/common/undertow
  • stubbornjava-examples/src/main/java/com/stubbornjava/examples/undertow/routing

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,22 @@ public class SimpleServer {
1212
private static final int DEFAULT_PORT = 8080;
1313
private static final String DEFAULT_HOST = "0.0.0.0";
1414

15-
private final Undertow undertow;
16-
private SimpleServer(Undertow undertow) {
17-
this.undertow = undertow;
15+
private final Undertow.Builder undertowBuilder;
16+
private SimpleServer(Undertow.Builder undertow) {
17+
this.undertowBuilder = undertow;
1818
}
1919

2020
/*
2121
* As you can see this class is not meant to abstract away the Undertow server,
2222
* its goal is simply to have some common configurations. We expose Undertow
2323
* if a different service needs to modify it in any way before we call start.
2424
*/
25-
public Undertow getUndertow() {
26-
return undertow;
25+
public Undertow.Builder getUndertow() {
26+
return undertowBuilder;
2727
}
2828

2929
public void start() {
30+
Undertow undertow = undertowBuilder.build();
3031
undertow.start();
3132
/*
3233
* Undertow logs this on its own but we generally set 3rd party
@@ -39,14 +40,13 @@ public void start() {
3940
}
4041

4142
public static SimpleServer simpleServer(HttpHandler handler) {
42-
Undertow undertow = Undertow.builder()
43+
Undertow.Builder undertow = Undertow.builder()
4344
/*
4445
* This setting is needed if you want to allow '=' as a value in a cookie.
4546
* If you base64 encode any cookie values you probably want it on.
4647
*/
4748
.setServerOption(UndertowOptions.ALLOW_EQUALS_IN_COOKIE_VALUE, true)
4849
.addHttpListener(DEFAULT_PORT, DEFAULT_HOST, handler)
49-
.build()
5050
;
5151
return new SimpleServer(undertow);
5252
}

‎stubbornjava-examples/src/main/java/com/stubbornjava/examples/undertow/routing/RoutingServer.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public static void main(String[] args) {
6262
*/
6363
SimpleServer server = SimpleServer.simpleServer(ROUTES);
6464
// See we have access to it here!
65-
Undertow undertow = server.getUndertow();
65+
Undertow.Builder undertow = server.getUndertow();
6666
server.start();
6767
}
6868
// {{end:server}}

0 commit comments

Comments
 (0)