Skip to content

Commit

Permalink
[#1441] Proper fix for none-localhost clients for @db connections
Browse files Browse the repository at this point in the history
  • Loading branch information
bplawler authored and mbknor committed Mar 28, 2012
1 parent e357f1b commit 8545992
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions framework/src/play/db/DBPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,25 @@ public class DBPlugin extends PlayPlugin {
public boolean rawInvocation(Request request, Response response) throws Exception {
if (Play.mode.isDev() && request.path.equals("/@db")) {
response.status = Http.StatusCode.MOVED;
String serverOptions[] = new String[] { };

// For H2 embeded database, we'll also start the Web console
if (h2Server != null) {
h2Server.stop();
}
h2Server = org.h2.tools.Server.createWebServer();
h2Server.start();

String domain = request.domain;
if (domain.equals(""))
domain = "localhost";
if (domain.equals("")) {
domain = "localhost";
}

if (!domain.equals("localhost")) {
serverOptions = new String[] {"-webAllowOthers"};
}

h2Server = org.h2.tools.Server.createWebServer(serverOptions);
h2Server.start();

response.setHeader("Location", "http://" + domain + ":8082/");
return true;
}
Expand Down

0 comments on commit 8545992

Please sign in to comment.