SpaRoute class
Route for serving Single Page Applications (SPAs) with fallback support.
Combines static file serving with automatic fallback to a specified file when requested files don't exist, enabling client-side routing.
pod.webServer.addRoute(
SpaRoute(
Directory('web/app'),
fallback: File('web/app/index.html'),
),
'/**',
);
- Inheritance
-
- Object
- HandlerObject
- Route
- SpaRoute
Constructors
- SpaRoute(Directory directory, {required File fallback, CacheControlFactory? cacheControlFactory, CacheBustingConfig? cacheBustingConfig})
- Creates a new SpaRoute.
Properties
- asHandler → Handler
-
Returns this HandlerObject as a Handler.
no setterinherited
- cacheBustingConfig → CacheBustingConfig?
-
Cache busting configuration for static files
final
- cacheControlFactory → CacheControlFactory?
-
Cache control factory for static files
final
- directory → Directory
-
The directory containing static files
final
- fallback → File
-
The fallback file (typically directory/index.html)
final
- hashCode → int
-
The hash code for this object.
no setterinherited
-
methods
→ Set<
Method> -
The methods this route will respond to, i.e. HTTP get or post.
finalinherited
- path → String
-
The suffix path this route will respond to.
finalinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
call(
Request req) → Future< Result> -
Handles a call to this route, by extracting Session from request and
forwarding to handleCall.
inherited
-
handleCall(
Session session, Request request) → FutureOr< Result> -
Handles a call to this route.
override
-
injectIn(
RelicRouter router) → void -
Adds this handler to the given
routerwith Method.get and path '/' Override to add differently.override -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited