Class SpaBundle

java.lang.Object
ru.vyarus.guicey.spa.SpaBundle
All Implemented Interfaces:
ru.vyarus.dropwizard.guice.module.installer.bundle.GuiceyBundle

public class SpaBundle extends Object implements ru.vyarus.dropwizard.guice.module.installer.bundle.GuiceyBundle
Provides support for SPA (for example, angular apps). Such applications often use html5 pretty url, like "/app/someroute/subroute". When user bookmark such url or simply refresh page, browser requests complete url on server and server must support it: redirect to main index page (without changing url, so client could handle routing).

Use dropwizard-assets servlet internally, but wraps it with special filter, which reacts on resource not found errors (by default, all calls pass to assets filter!). Applies no-cache header for index page.

You can register multiple SPA applications on main or admin contexts (or both). All applications must have unique names. In case of duplicate names or mapping on the same path, error will be thrown.

Since:
02.04.2017
  • Field Details

  • Constructor Details

    • SpaBundle

      public SpaBundle()
  • Method Details

    • initialize

      public void initialize(ru.vyarus.dropwizard.guice.module.installer.bundle.GuiceyBootstrap bootstrap)
      Specified by:
      initialize in interface ru.vyarus.dropwizard.guice.module.installer.bundle.GuiceyBundle
    • run

      public void run(ru.vyarus.dropwizard.guice.module.installer.bundle.GuiceyEnvironment environment)
      Specified by:
      run in interface ru.vyarus.dropwizard.guice.module.installer.bundle.GuiceyBundle
    • app

      public static SpaBundle.Builder app(String name, String resourcePath, String uriPath)
      Register SPA application in main context. Note: application names must be unique (when you register multiple SPA applications.
      Parameters:
      name - application name (used as servlet name)
      resourcePath - application resources classpath location (may use slash or dots as separator)
      uriPath - mapping uri
      Returns:
      builder instance for SPA configuration
    • adminApp

      public static SpaBundle.Builder adminApp(String name, String resourcePath, String uriPath)
      Register SPA application in admin context. Note: application names must be unique (when you register multiple SPA applications.
      Parameters:
      name - application name (used as servlet name)
      resourcePath - path to application resources (classpath)
      uriPath - mapping uri
      Returns:
      builder instance for SPA configuration