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> |
ALL()
Starts the creation of a route matching any HTTP method,
and on any path.
|
RouteBuilder<R> |
ALL(String path)
Starts the creation of a route matching any HTTP method.
|
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()
Starts the creation of a
DELETE route,
for all path. |
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()
Starts the creation of a
GET route,
for all path. |
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()
Starts the creation of a
HEAD route,
for all path. |
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.
|
RouteBuilder<R> |
methods(HttpMethod... httpMethods)
Starts the creation of a route matching the specified
HTTP methods and on any path.
|
RouteBuilder<R> |
methods(Set<HttpMethod> httpMethods)
Starts the creation of a route matching the specified
HTTP methods and on any path.
|
RouteBuilder<R> |
methods(String path,
HttpMethod... httpMethods)
Starts the creation of a route matching the specified
HTTP methods.
|
RouteBuilder<R> |
methods(String path,
Set<HttpMethod> httpMethods)
Starts the creation of a route matching the specified
HTTP methods.
|
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()
Starts the creation of a
OPTIONS route,
for all path. |
RouteBuilder<R> |
OPTIONS(String path)
Starts the creation of a
OPTIONS route. |
RouteBuilder<R> |
PATCH()
Starts the creation of a
PATCH route,
for all path. |
RouteBuilder<R> |
PATCH(String path)
Starts the creation of a
PATCH route. |
RouteBuilder<R> |
POST()
Starts the creation of a
POST route,
for all path. |
RouteBuilder<R> |
POST(String path)
Starts the creation of a
POST route. |
RouteBuilder<R> |
PUT()
Starts the creation of a
PUT route,
for all path. |
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 application routes (not the
ones added by Spincast and plugins).
|
void |
removeAllRoutes(boolean removeSpincastAndPluginsRoutesToo)
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> |
TRACE()
Starts the creation of a
TRACE route,
for all path. |
RouteBuilder<R> |
TRACE(String path)
Starts the creation of a
TRACE route,
at the specified position. |
WebsocketRouteBuilder<R,W> |
websocket(String path)
Starts the creation of a
Websocket route. |
static final String DEFAULT_ROUTE_PATH
RouteBuilder<R> GET()
GET route,
for all path. Same as GET("/*{path}").RouteBuilder<R> GET(String path)
GET route.RouteBuilder<R> POST()
POST route,
for all path. Same as POST("/*{path}").RouteBuilder<R> POST(String path)
POST route.RouteBuilder<R> PUT()
PUT route,
for all path. Same as PUT("/*{path}").RouteBuilder<R> PUT(String path)
PUT route.RouteBuilder<R> DELETE()
DELETE route,
for all path. Same as DELETE("/*{path}").RouteBuilder<R> DELETE(String path)
DELETE route.RouteBuilder<R> OPTIONS()
OPTIONS route,
for all path. Same as OPTIONS("/*{path}").RouteBuilder<R> OPTIONS(String path)
OPTIONS route.RouteBuilder<R> TRACE()
TRACE route,
for all path. Same as TRACE("/*{path}").RouteBuilder<R> TRACE(String path)
TRACE route,
at the specified position.RouteBuilder<R> HEAD()
HEAD route,
for all path. Same as HEAD("/*{path}").RouteBuilder<R> HEAD(String path)
HEAD route.RouteBuilder<R> PATCH()
PATCH route,
for all path. Same as PATCH("/*{path}").RouteBuilder<R> PATCH(String path)
PATCH route.RouteBuilder<R> ALL()
ALL("/*{path}").RouteBuilder<R> ALL(String path)
RouteBuilder<R> methods(Set<HttpMethod> httpMethods)
methods("/*{path}", httpMethods).RouteBuilder<R> methods(String path, Set<HttpMethod> httpMethods)
RouteBuilder<R> methods(HttpMethod... httpMethods)
methods("/*{path}", httpMethods).RouteBuilder<R> methods(String path, HttpMethod... httpMethods)
void exception(Handler<R> handler)
Synonym of :
ALL("/*{path}").exception().handle(handler)
void exception(String path, Handler<R> handler)
Synonym of :
ALL(path).exception().handle(handler)
void notFound(Handler<R> handler)
Synonym of :
ALL("/*{path}").notFound().handle(handler)
void notFound(String path, Handler<R> handler)
Synonym of :
ALL(path).notFound().handle(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 removeSpincastAndPluginsRoutesToo)
removeSpincastAndPluginsRoutesToo - Should the routes added by
Spincast and plugins 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 © 2019. All rights reserved.