public interface Router<R extends RequestContext<?>,W extends WebsocketContext<?>>
| Modifier and Type | Field and Description |
|---|---|
static String |
DEFAULT_ROUTE_PATH
The default path used when Spincast creates routes by
itself.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addRoute(Route<R> route)
Adds a route, directly.
|
void |
addRouteParamPatternAlias(String alias,
String pattern)
Adds an alias for a path pattern.
|
void |
addStaticResource(StaticResource<R> staticResource)
Adds a
static resource route, directly. |
void |
addWebsocketRoute(WebsocketRoute<R,W> websocketRoute)
Adds a Websocket route, directly.
|
RouteBuilder<R> |
after()
Creates an "after" filter.
|
RouteBuilder<R> |
after(String path)
Creates an "after" filter.
|
RouteBuilder<R> |
ALL(String path)
Starts the creation of a route matching any HTTP method.
|
RouteBuilder<R> |
before()
Creates a "before" filter.
|
RouteBuilder<R> |
before(String path)
Creates a "before" filter.
|
RouteBuilder<R> |
beforeAndAfter()
Creates a "before" and an "after" filters.
|
RouteBuilder<R> |
beforeAndAfter(String path)
Creates a "before" and an "after" filters.
|
void |
cors()
Enables Cross-Origin Resource Sharing (Cors) on all
matching requests (except the static resources,
for whom cors has to be activated directly!)
|
void |
cors(Set<String> allowedOrigins)
Enables Cross-Origin Resource Sharing (Cors) on
matching requests (except the static resources,
for whom cors has to be activated directly!)
|
void |
cors(Set<String> allowedOrigins,
Set<String> extraHeadersAllowedToBeRead)
Enables Cross-Origin Resource Sharing (Cors) on
matching requests (except the static resources,
for whom cors has to be activated directly!)
|
void |
cors(Set<String> allowedOrigins,
Set<String> extraHeadersAllowedToBeRead,
Set<String> extraHeadersAllowedToBeSent)
Enables Cross-Origin Resource Sharing (Cors) on
matching requests (except the static resources,
for whom cors has to be activated directly!)
|
void |
cors(Set<String> allowedOrigins,
Set<String> extraHeadersAllowedToBeRead,
Set<String> extraHeadersAllowedToBeSent,
boolean allowCookies)
Enables Cross-Origin Resource Sharing (Cors) on
matching requests (except the static resources,
for whom cors has to be activated directly!)
|
void |
cors(Set<String> allowedOrigins,
Set<String> extraHeadersAllowedToBeRead,
Set<String> extraHeadersAllowedToBeSent,
boolean allowCookies,
Set<HttpMethod> allowedMethods)
Enables Cross-Origin Resource Sharing (Cors) on
matching requests (except the static resources,
for whom cors has to be activated directly!)
|
void |
cors(Set<String> allowedOrigins,
Set<String> extraHeadersAllowedToBeRead,
Set<String> extraHeadersAllowedToBeSent,
boolean allowCookies,
Set<HttpMethod> allowedMethods,
int maxAgeInSeconds)
Enables Cross-Origin Resource Sharing (Cors) on
matching requests (except the static resources,
for whom cors has to be activated directly!)
|
void |
cors(String path)
Enables Cross-Origin Resource Sharing (Cors) on all
requests matching the specified path (except the static resources,
for whom cors has to be activated directly!)
|
void |
cors(String path,
Set<String> allowedOrigins)
Enables Cross-Origin Resource Sharing (Cors) on
requests matching the specified path (except the static resources,
for whom cors has to be activated directly!)
|
void |
cors(String path,
Set<String> allowedOrigins,
Set<String> extraHeadersAllowedToBeRead)
Enables Cross-Origin Resource Sharing (Cors) on
requests matching the specified path (except the static resources,
for whom cors has to be activated directly!)
|
void |
cors(String path,
Set<String> allowedOrigins,
Set<String> extraHeadersAllowedToBeRead,
Set<String> extraHeadersAllowedToBeSent)
Enables Cross-Origin Resource Sharing (Cors) on
requests matching the specified path (except the static resources,
for whom cors has to be activated directly!)
|
void |
cors(String path,
Set<String> allowedOrigins,
Set<String> extraHeadersAllowedToBeRead,
Set<String> extraHeadersAllowedToBeSent,
boolean allowCookies)
Enables Cross-Origin Resource Sharing (Cors) on
requests matching the specified path (except the static resources,
for whom cors has to be activated directly!)
|
void |
cors(String path,
Set<String> allowedOrigins,
Set<String> extraHeadersAllowedToBeRead,
Set<String> extraHeadersAllowedToBeSent,
boolean allowCookies,
Set<HttpMethod> allowedMethods)
Enables Cross-Origin Resource Sharing (Cors) on
requests matching the specified path (except the static resources,
for whom cors has to be activated directly!)
|
void |
cors(String path,
Set<String> allowedOrigins,
Set<String> extraHeadersAllowedToBeRead,
Set<String> extraHeadersAllowedToBeSent,
boolean allowCookies,
Set<HttpMethod> allowedMethods,
int maxAgeInSeconds)
Enables Cross-Origin Resource Sharing (Cors) on
requests matching the specified path (except the static resources,
for whom cors has to be activated directly!)
|
RouteBuilder<R> |
DELETE(String path)
Starts the creation of a
DELETE route. |
StaticResourceBuilder<R> |
dir(String url)
Start the creation of a
static resource directory. |
void |
exception(Handler<R> handler)
Creates a route considered during an "Exception" routing process.
|
void |
exception(String path,
Handler<R> handler)
Creates a route considered during an "Exception" routing process.
|
StaticResourceBuilder<R> |
file(String url)
Start the creation of a
static resource file. |
RouteBuilder<R> |
GET(String path)
Starts the creation of a
GET route. |
List<Route<R>> |
getGlobalAfterFiltersRoutes()
Gets the global "after" filters.
|
List<Route<R>> |
getGlobalBeforeFiltersRoutes()
Gets the global "before" filters.
|
List<Route<R>> |
getMainRoutes()
Gets the main routes.
|
Route<R> |
getRoute(String routeId)
Gets a route using its
routeId. |
Map<String,String> |
getRouteParamPatternAliases()
The path patterns' aliases.
|
RouteBuilder<R> |
HEAD(String path)
Starts the creation of a
HEAD route. |
void |
httpAuth(String pathPrefix,
String realmName)
Creates HTTP authentication protection (realm) for the
specified path prefix.
|
void |
notFound(Handler<R> handler)
Creates a route considered during an "Not Found" routing process.
|
void |
notFound(String path,
Handler<R> handler)
Creates a route considered during an "Not Found" routing process.
|
RouteBuilder<R> |
OPTIONS(String path)
Starts the creation of a
OPTIONS route. |
RouteBuilder<R> |
PATCH(String path)
Starts the creation of a
PATCH route. |
RouteBuilder<R> |
POST(String path)
Starts the creation of a
POST route. |
RouteBuilder<R> |
PUT(String path)
Starts the creation of a
PUT route. |
RedirectRuleBuilder |
redirect(String oldPath)
Starts the creation of a redirection rule.
|
void |
removeAllRoutes()
Removes all routes, except the one Spincast
addds automatically (their ids start with "spincast_").
|
void |
removeAllRoutes(boolean removeSpincastRoutesToo)
Removes all routes.
|
void |
removeRoute(String routeId)
Removes a route using its
routeId. |
RoutingResult<R> |
route(R requestContext)
Find the route to use to handle the current request.
|
RoutingResult<R> |
route(R requestContext,
RoutingType routingType)
Find the route to use to handle the current request, given the
specified routing type.
|
RouteBuilder<R> |
SOME(String path,
HttpMethod... httpMethods)
Starts the creation of a route matching the specified
HTTP methods.
|
RouteBuilder<R> |
SOME(String path,
Set<HttpMethod> httpMethods)
Starts the creation of a route matching the specified
HTTP methods.
|
RouteBuilder<R> |
TRACE(String path)
Starts the creation of a
TRACE route. |
WebsocketRouteBuilder<R,W> |
websocket(String path)
Starts the creation of a
Websocket route. |
static final String DEFAULT_ROUTE_PATH
RouteBuilder<R> GET(String path)
GET route.RouteBuilder<R> POST(String path)
POST route.RouteBuilder<R> PUT(String path)
PUT route.RouteBuilder<R> DELETE(String path)
DELETE route.RouteBuilder<R> OPTIONS(String path)
OPTIONS route.RouteBuilder<R> TRACE(String path)
TRACE route.RouteBuilder<R> HEAD(String path)
HEAD route.RouteBuilder<R> PATCH(String path)
PATCH route.RouteBuilder<R> ALL(String path)
RouteBuilder<R> SOME(String path, Set<HttpMethod> httpMethods)
RouteBuilder<R> SOME(String path, HttpMethod... httpMethods)
RouteBuilder<R> before()
ALL("/*{path}").pos(-10)
and with the Routing types as returned by
SpincastRouterConfig#getFilterDefaultRoutingTypes()RouteBuilder<R> before(String path)
ALL(path).pos(-10)
and with the Routing types as returned by
SpincastRouterConfig#getFilterDefaultRoutingTypes()RouteBuilder<R> after()
ALL("/*{path}").pos(10)
and with the Routing types as returned by
SpincastRouterConfig#getFilterDefaultRoutingTypes()RouteBuilder<R> after(String path)
ALL(path).pos(10))
and with the Routing types as returned by
SpincastRouterConfig#getFilterDefaultRoutingTypes()RouteBuilder<R> beforeAndAfter()
ALL("/*{path}").pos(-10)
and
ALL("/*{path}").pos(10)
and with the Routing types as returned by
SpincastRouterConfig#getFilterDefaultRoutingTypes()RouteBuilder<R> beforeAndAfter(String path)
ALL(path).pos(-10)
and
ALL(path).pos(10)
and with the Routing types as returned by
SpincastRouterConfig#getFilterDefaultRoutingTypes()void exception(Handler<R> handler)
ALL("/*{path}").exception().save(handler)void exception(String path, Handler<R> handler)
ALL(path).exception().save(handler)void notFound(Handler<R> handler)
ALL("/*{path}").notFound().save(handler)void notFound(String path, Handler<R> handler)
ALL(path).notFound().save(handler)StaticResourceBuilder<R> file(String url)
static resource file.
Only a GET or a HEAD request will be able
to access this resource.
No "before" and "after" filters will be applied to those, since the request won't even reach the framework.
url - The url which will trigger the output of this
static resource.StaticResourceBuilder<R> dir(String url)
static resource directory.
Only a GET or a HEAD request will be able
to access the resources below this directory.
No "before" and "after" filters will be applied to those, since the request won't even reach the framework.
url - The url which will trigger the output of this
static resource.void cors()
SpincastFilters#cors(R context)void cors(Set<String> allowedOrigins)
SpincastFilters#cors(R context,
Set<String> allowedOrigins)void cors(Set<String> allowedOrigins, Set<String> extraHeadersAllowedToBeRead)
SpincastFilters#cors(R context,
Set<String> allowedOrigins,
Set<String> extraHeadersAllowedToBeReadt)void cors(Set<String> allowedOrigins, Set<String> extraHeadersAllowedToBeRead, Set<String> extraHeadersAllowedToBeSent)
SpincastFilters#cors(R context,
Set<String> allowedOrigins,
Set<String> extraHeadersAllowedToBeRead,
Set<String> extraHeadersAllowedToBeSent)void cors(Set<String> allowedOrigins, Set<String> extraHeadersAllowedToBeRead, Set<String> extraHeadersAllowedToBeSent, boolean allowCookies)
SpincastFilters#cors(R context,
Set<String> allowedOrigins,
Set<String> extraHeadersAllowedToBeRead,
Set<String> extraHeadersAllowedToBeSent,
boolean allowCookies)void cors(Set<String> allowedOrigins, Set<String> extraHeadersAllowedToBeRead, Set<String> extraHeadersAllowedToBeSent, boolean allowCookies, Set<HttpMethod> allowedMethods)
SpincastFilters#cors(R context,
Set<String> allowedOrigins,
Set<String> extraHeadersAllowedToBeRead,
Set<String> extraHeadersAllowedToBeSent,
boolean allowCookies,
Set<HttpMethod> allowedMethods)void cors(Set<String> allowedOrigins, Set<String> extraHeadersAllowedToBeRead, Set<String> extraHeadersAllowedToBeSent, boolean allowCookies, Set<HttpMethod> allowedMethods, int maxAgeInSeconds)
SpincastFilters#cors(R context,
Set<String> allowedOrigins,
Set<String> extraHeadersAllowedToBeRead,
Set<String> extraHeadersAllowedToBeSent,
boolean allowCookies,
Set<HttpMethod> allowedMethods,
int maxAgeInSeconds)void cors(String path)
SpincastFilters#cors(R context)void cors(String path, Set<String> allowedOrigins)
SpincastFilters#cors(R context,
Set<String> allowedOrigins)void cors(String path, Set<String> allowedOrigins, Set<String> extraHeadersAllowedToBeRead)
SpincastFilters#cors(R context,
Set<String> allowedOrigins,
Set<String> extraHeadersAllowedToBeRead)void cors(String path, Set<String> allowedOrigins, Set<String> extraHeadersAllowedToBeRead, Set<String> extraHeadersAllowedToBeSent)
SpincastFilters#cors(R context,
Set<String> allowedOrigins,
Set<String> extraHeadersAllowedToBeRead,
Set<String> extraHeadersAllowedToBeSent)void cors(String path, Set<String> allowedOrigins, Set<String> extraHeadersAllowedToBeRead, Set<String> extraHeadersAllowedToBeSent, boolean allowCookies)
SpincastFilters#cors(R context,
Set<String> allowedOrigins,
Set<String> extraHeadersAllowedToBeRead,
Set<String> extraHeadersAllowedToBeSent,
boolean allowCookies)void cors(String path, Set<String> allowedOrigins, Set<String> extraHeadersAllowedToBeRead, Set<String> extraHeadersAllowedToBeSent, boolean allowCookies, Set<HttpMethod> allowedMethods)
SpincastFilters#cors(R context,
Set<String> allowedOrigins,
Set<String> extraHeadersAllowedToBeRead,
Set<String> extraHeadersAllowedToBeSent,
boolean allowCookies,
Set<HttpMethod> allowedMethods)void cors(String path, Set<String> allowedOrigins, Set<String> extraHeadersAllowedToBeRead, Set<String> extraHeadersAllowedToBeSent, boolean allowCookies, Set<HttpMethod> allowedMethods, int maxAgeInSeconds)
SpincastFilters#cors(R context,
Set<String> allowedOrigins,
Set<String> extraHeadersAllowedToBeRead,
Set<String> extraHeadersAllowedToBeSent,
boolean allowCookies,
Set<HttpMethod> allowedMethods,
int maxAgeInSeconds)void addStaticResource(StaticResource<R> staticResource)
static resource route, directly.RoutingResult<R> route(R requestContext)
null if no route matches.RoutingResult<R> route(R requestContext, RoutingType routingType)
null if no route matches.void removeAllRoutes()
void removeAllRoutes(boolean removeSpincastRoutesToo)
removeSpincastRoutesToo - Should the routes added by
Spincast be removed too?void removeRoute(String routeId)
routeId.List<Route<R>> getGlobalBeforeFiltersRoutes()
List<Route<R>> getGlobalAfterFiltersRoutes()
void addRouteParamPatternAlias(String alias, String pattern)
"/${param1:<XXX>}" : here "XXX" is the alias for the
regular expression pattern to use.Map<String,String> getRouteParamPatternAliases()
void httpAuth(String pathPrefix, String realmName)
WebsocketRouteBuilder<R,W> websocket(String path)
Websocket route.void addWebsocketRoute(WebsocketRoute<R,W> websocketRoute)
RedirectRuleBuilder redirect(String oldPath)
oldPath - The old path that needs to be redirected.Copyright © 2016. All rights reserved.