@@ -33,6 +33,7 @@ public static class SimpleWebServerBuilder {
3333 private int port ;
3434 private String routerPath = "/api" ;
3535 private String appBase = null ;
36+ private String bindInterface = "0.0.0.0" ;
3637 private RestxMainRouter router ;
3738 public SimpleWebServerBuilder setPort (int port ) {
3839 this .port = port ;
@@ -49,19 +50,24 @@ public SimpleWebServerBuilder setAppBase(String appBase) {
4950 return this ;
5051 }
5152
53+ public SimpleWebServerBuilder setBindInterface (String bindInterface ) {
54+ this .bindInterface = bindInterface ;
55+ return this ;
56+ }
57+
5258 public SimpleWebServerBuilder setRouter (RestxMainRouter router ) {
5359 this .router = router ;
5460 return this ;
5561 }
5662
5763 public SimpleWebServer build () {
5864 if (router == null ) {
59- return new SimpleWebServer (routerPath , appBase , port ) {
65+ return new SimpleWebServer (routerPath , appBase , port , bindInterface ) {
6066 @ Override
6167 protected RestxMainRouter setupRouter () {
6268 return RestxMainRouterFactory .newInstance (
6369 serverId ,
64- Optional .of (WebServers .baseUri ("0.0.0.0" , port , routerPath )));
70+ Optional .of (WebServers .baseUri (bindInterface , port , routerPath )));
6571 }
6672
6773 @ Override
@@ -72,7 +78,7 @@ public synchronized void stop() throws Exception {
7278 }
7379 };
7480 } else {
75- return new SimpleWebServer (routerPath , appBase , port ) {
81+ return new SimpleWebServer (routerPath , appBase , port , bindInterface ) {
7682 @ Override
7783 protected RestxMainRouter setupRouter () {
7884 return router ;
@@ -94,8 +100,8 @@ public static SimpleWebServerBuilder builder() {
94100 private RestxMainRouter router ;
95101 private Connection connection ;
96102
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" );
99105
100106 this .routerPath = routerPath ;
101107 this .httpSettings = Factory .getInstance ().getComponent (HttpSettings .class );
@@ -154,7 +160,7 @@ public static WebServerSupplier simpleWebServerSupplier() {
154160 return new WebServerSupplier () {
155161 @ Override
156162 public WebServer newWebServer (int port ) {
157- return SimpleWebServer .builder ().setPort (port ).build ();
163+ return SimpleWebServer .builder ().setPort (port ).setBindInterface ( "0.0.0.0" ). build ();
158164 }
159165 };
160166 }
0 commit comments