@@ -33,6 +33,7 @@ public static class SimpleWebServerBuilder {
33
33
private int port ;
34
34
private String routerPath = "/api" ;
35
35
private String appBase = null ;
36
+ private String bindInterface = "0.0.0.0" ;
36
37
private RestxMainRouter router ;
37
38
public SimpleWebServerBuilder setPort (int port ) {
38
39
this .port = port ;
@@ -49,19 +50,24 @@ public SimpleWebServerBuilder setAppBase(String appBase) {
49
50
return this ;
50
51
}
51
52
53
+ public SimpleWebServerBuilder setBindInterface (String bindInterface ) {
54
+ this .bindInterface = bindInterface ;
55
+ return this ;
56
+ }
57
+
52
58
public SimpleWebServerBuilder setRouter (RestxMainRouter router ) {
53
59
this .router = router ;
54
60
return this ;
55
61
}
56
62
57
63
public SimpleWebServer build () {
58
64
if (router == null ) {
59
- return new SimpleWebServer (routerPath , appBase , port ) {
65
+ return new SimpleWebServer (routerPath , appBase , port , bindInterface ) {
60
66
@ Override
61
67
protected RestxMainRouter setupRouter () {
62
68
return RestxMainRouterFactory .newInstance (
63
69
serverId ,
64
- Optional .of (WebServers .baseUri ("0.0.0.0" , port , routerPath )));
70
+ Optional .of (WebServers .baseUri (bindInterface , port , routerPath )));
65
71
}
66
72
67
73
@ Override
@@ -72,7 +78,7 @@ public synchronized void stop() throws Exception {
72
78
}
73
79
};
74
80
} else {
75
- return new SimpleWebServer (routerPath , appBase , port ) {
81
+ return new SimpleWebServer (routerPath , appBase , port , bindInterface ) {
76
82
@ Override
77
83
protected RestxMainRouter setupRouter () {
78
84
return router ;
@@ -94,8 +100,8 @@ public static SimpleWebServerBuilder builder() {
94
100
private RestxMainRouter router ;
95
101
private Connection connection ;
96
102
97
- private SimpleWebServer (String routerPath , String appBase , int port ) {
98
- super (appBase , port , "localhost" , "SimpleFrameowkr" , "org.simpleframework" , "simple" );
103
+ private SimpleWebServer (String routerPath , String appBase , int port , String bindInterface ) {
104
+ super (appBase , port , bindInterface , "SimpleFrameowkr" , "org.simpleframework" , "simple" );
99
105
100
106
this .routerPath = routerPath ;
101
107
this .httpSettings = Factory .getInstance ().getComponent (HttpSettings .class );
@@ -154,7 +160,7 @@ public static WebServerSupplier simpleWebServerSupplier() {
154
160
return new WebServerSupplier () {
155
161
@ Override
156
162
public WebServer newWebServer (int port ) {
157
- return SimpleWebServer .builder ().setPort (port ).build ();
163
+ return SimpleWebServer .builder ().setPort (port ).setBindInterface ( "0.0.0.0" ). build ();
158
164
}
159
165
};
160
166
}
0 commit comments