-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dabc6c6
commit 5572140
Showing
2 changed files
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
server/jetty/src/main/java/io/deephaven/server/jetty/JsPlugins.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |