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 java.lang.Object implements ru.vyarus.dropwizard.guice.module.installer.bundle.GuiceyBundleProvides 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 Modifier and Type Class Description static classSpaBundle.BuilderSpa bundle builder.
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringDEFAULT_PATTERN
-
Constructor Summary
Constructors Constructor Description SpaBundle()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static SpaBundle.BuilderadminApp(java.lang.String name, java.lang.String resourcePath, java.lang.String uriPath)Register SPA application in admin context.static SpaBundle.Builderapp(java.lang.String name, java.lang.String resourcePath, java.lang.String uriPath)Register 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 Detail
-
DEFAULT_PATTERN
public static final java.lang.String DEFAULT_PATTERN
- See Also:
- Constant Field Values
-
-
Method Detail
-
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
public static SpaBundle.Builder app(java.lang.String name, java.lang.String resourcePath, java.lang.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(java.lang.String name, java.lang.String resourcePath, java.lang.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
-
-