Java Code Examples for spark.staticfiles.StaticFilesConfiguration

The following examples show how to use spark.staticfiles.StaticFilesConfiguration. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: gocd   Source File:    License: Apache License 2.0 6 votes vote down vote up
public void destroy() {
    //hacky way to reset the state of the routes between tests
    //see Service.stop(), (not invoked directly because it spawns a thread)
    try {
        Method getInstance = Spark.class.getDeclaredMethod("getInstance");
        Service service = (Service) getInstance.invoke(null);
        //Dependent on current version of Spark
        //This is likely to fail in case of upgrades
        clear(service, "routes", Routes.class);
        clear(service, "exceptionMapper", ExceptionMapper.class);
        clear(service, "staticFilesConfiguration", StaticFilesConfiguration.class);
        ReflectionTestUtils.setField(service, "initialized", false);
    } catch (Exception e) {
        throw new RuntimeException(e);
Example 2
Source Project: freeacs   Source File:    License: MIT License 5 votes vote down vote up
public EmbeddedServer create(
    Routes routeMatcher,
    StaticFilesConfiguration staticFilesConfiguration,
    ExceptionMapper exceptionMapper,
    boolean hasMultipleHandler) {
  MatcherFilter matcherFilter =
      new MatcherFilter(
          routeMatcher, staticFilesConfiguration, exceptionMapper, false, hasMultipleHandler);
  JettyHandler handler = new JettyHandler(matcherFilter);
  return new EmbeddedJettyServer(new JettyServer(maxHttpPostSize, maxFormKeys), handler);
Example 3
public EmbeddedServer create(Routes routes, StaticFilesConfiguration staticFilesConfiguration, ExceptionMapper exceptionMapper, boolean multipleHandlers) {
    if (embeddedServer == null) {
        LambdaEmbeddedServerFactory.embeddedServer = new LambdaEmbeddedServer(routes, staticFilesConfiguration, exceptionMapper, multipleHandlers);
    return embeddedServer;
Example 4
LambdaEmbeddedServer(Routes routes, StaticFilesConfiguration filesConfig, ExceptionMapper exceptionMapper, boolean multipleHandlers) {
    applicationRoutes = routes;
    staticFilesConfiguration = filesConfig;
    hasMultipleHandler = multipleHandlers;
    this.exceptionMapper = exceptionMapper;

    // try to initialize the filter here.
    sparkFilter = new MatcherFilter(applicationRoutes, staticFilesConfiguration, exceptionMapper, true, hasMultipleHandler);
Example 5
Source Project: ache   Source File:    License: Apache License 2.0 5 votes vote down vote up
public StaticFileHandlerFilter(List<String> indexHtmlPaths, String basePath) {
    this.staticFilesHandler = new StaticFilesConfiguration();
    this.patterns = WildcardMatcher.fromWhitelist(indexHtmlPaths);
    this.basePath = normalizeBasePath(basePath);
    this.indexHtml = readIndexHtmlFile();