Package ru.vyarus.guicey.spa
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
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic SpaBundle.BuilderRegister SPA application in admin context.static SpaBundle.BuilderRegister SPA application in main context.voidinitialize(ru.vyarus.dropwizard.guice.module.installer.bundle.GuiceyBootstrap bootstrap) voidrun(ru.vyarus.dropwizard.guice.module.installer.bundle.GuiceyEnvironment environment)
-
Field Details
-
DEFAULT_PATTERN
Default asset pattern.- See Also:
-
-
Constructor Details
-
SpaBundle
public SpaBundle()
-
-
Method Details
-
initialize
public void initialize(ru.vyarus.dropwizard.guice.module.installer.bundle.GuiceyBootstrap bootstrap) - Specified by:
initializein interfaceru.vyarus.dropwizard.guice.module.installer.bundle.GuiceyBundle
-
run
public void run(ru.vyarus.dropwizard.guice.module.installer.bundle.GuiceyEnvironment environment) - Specified by:
runin interfaceru.vyarus.dropwizard.guice.module.installer.bundle.GuiceyBundle
-
app
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
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
-