Skip to content

Commit 79ae086

Browse files
unidevelyingsu00
authored andcommitted
Enable welcome page for UI path /ui/dev
1 parent 3a162d5 commit 79ae086

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

presto-main/src/main/java/com/facebook/presto/server/CoordinatorModule.java

+15-6
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import com.facebook.airlift.concurrent.BoundedExecutor;
1717
import com.facebook.airlift.configuration.AbstractConfigurationAwareModule;
1818
import com.facebook.airlift.discovery.server.EmbeddedDiscoveryModule;
19+
import com.facebook.airlift.http.server.HttpServerBinder.HttpResourceBinding;
1920
import com.facebook.presto.client.QueryResults;
2021
import com.facebook.presto.cost.CostCalculator;
2122
import com.facebook.presto.cost.CostCalculator.EstimatedExchanges;
@@ -139,15 +140,23 @@
139140
public class CoordinatorModule
140141
extends AbstractConfigurationAwareModule
141142
{
143+
private static final String DEFAULT_WEBUI_CSP =
144+
"default-src 'self'; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; " +
145+
"font-src 'self' https://fonts.gstatic.com; frame-ancestors 'self'; img-src http: https: data:";
146+
147+
private HttpResourceBinding webUIBinder(Binder binder, String path, String classPathResourceBase)
148+
{
149+
return httpServerBinder(binder).bindResource(path, classPathResourceBase)
150+
.withExtraHeader(HttpHeaders.X_CONTENT_TYPE_OPTIONS, "nosniff")
151+
.withExtraHeader(HttpHeaders.CONTENT_SECURITY_POLICY, DEFAULT_WEBUI_CSP);
152+
}
153+
142154
@Override
143155
protected void setup(Binder binder)
144156
{
145-
httpServerBinder(binder).bindResource("/ui", "webapp").withWelcomeFile("index.html")
146-
.withExtraHeader(HttpHeaders.X_CONTENT_TYPE_OPTIONS, "nosniff")
147-
.withExtraHeader(HttpHeaders.CONTENT_SECURITY_POLICY, "default-src 'self'; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; font-src 'self' https://fonts.gstatic.com; frame-ancestors 'self'; img-src http: https: data:");
148-
httpServerBinder(binder).bindResource("/tableau", "webapp/tableau")
149-
.withExtraHeader(HttpHeaders.X_CONTENT_TYPE_OPTIONS, "nosniff")
150-
.withExtraHeader(HttpHeaders.CONTENT_SECURITY_POLICY, "default-src 'self'; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; font-src 'self' https://fonts.gstatic.com; frame-ancestors 'self'; img-src http: https: data:");
157+
webUIBinder(binder, "/ui/dev", "webapp/dev").withWelcomeFile("index.html");
158+
webUIBinder(binder, "/ui", "webapp").withWelcomeFile("index.html");
159+
webUIBinder(binder, "/tableau", "webapp/tableau");
151160

152161
// discovery server
153162
install(installModuleIf(EmbeddedDiscoveryConfig.class, EmbeddedDiscoveryConfig::isEnabled, new EmbeddedDiscoveryModule()));

0 commit comments

Comments
 (0)