Skip to content

Commit

Permalink
Add js-plugins pre-built support
Browse files Browse the repository at this point in the history
  • Loading branch information
devinrsmith committed Nov 2, 2022
1 parent dabc6c6 commit 5572140
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ public JettyBackedGrpcServer(
// Wire up the provided grpc filter
context.addFilter(new FilterHolder(filter), "/*", EnumSet.noneOf(DispatcherType.class));

// Set up /js-plugins/*
JsPlugins.maybeAdd(context);

// Set up websockets for grpc-web - depending on configuration, we can register both in case we encounter a
// client using "vanilla"
// grpc-websocket, that can't multiplex all streams on a single socket
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package io.deephaven.server.jetty;

import io.deephaven.configuration.Configuration;
import org.eclipse.jetty.servlet.DefaultServlet;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.servlet.ServletHolder;

class JsPlugins {

public static void maybeAdd(ServletContextHandler context) {
// Note: this would probably be better to live in JettyConfig - but until we establish more formal expectations
// for js plugin configuration and workflows, we'll keep this here.
final String resourceBase =
Configuration.getInstance().getStringWithDefault("deephaven.jsPlugins.resourceBase", null);
if (resourceBase == null) {
return;
}
context.addServlet(createServlet("js-plugins", resourceBase), "/js-plugins/*");
}

private static ServletHolder createServlet(String name, String resourceBase) {
final ServletHolder jsPlugins = new ServletHolder(name, DefaultServlet.class);
jsPlugins.setInitParameter("resourceBase", resourceBase);
jsPlugins.setInitParameter("pathInfoOnly", "true");
jsPlugins.setInitParameter("dirAllowed", "false");
jsPlugins.setAsyncSupported(true);
return jsPlugins;
}
}

0 comments on commit 5572140

Please sign in to comment.