public interface IRouter<R extends IRequestContext<?>,W extends IWebsocketContext<?>>
| 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(IRoute<R> route)
Adds a route, directly.
|
void |
addRouteParamPatternAlias(String alias,
String pattern)
Adds an alias for a path pattern.
|
void |
addStaticResource(IStaticResource<R> staticResource)
Adds a
static resource route, directly. |
void |
addWebsocketRoute(IWebsocketRoute<R,W> websocketRoute)
Adds a Websocket route, directly.
|
void |
after(IHandler<R> handler)
Creates an "after" filter.
|
void |
after(String path,
IHandler<R> handler)
Creates an "after" filter.
|
IRouteBuilder<R> |
ALL(String path)
Starts the creation of a route matching any HTTP method.
|
void |
before(IHandler<R> handler)
Creates a "before" filter.
|
void |
before(String path,
IHandler<R> handler)
Creates a "before" filter.
|
void |
beforeAndAfter(IHandler<R> handler)
Creates a "before" and an "after" filters.
|
void |
beforeAndAfter(String path,
IHandler<R> handler)
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!)
|
IRouteBuilder<R> |
DELETE(String path)
Starts the creation of a
DELETE route. |
IStaticResourceBuilder<R> |
dir(String url)
Start the creation of a
static resource directory. |
void |
exception(IHandler<R> handler)
Creates a route considered during an "Exception" routing process.
|
void |
exception(String path,
IHandler<R> handler)
Creates a route considered during an "Exception" routing process.
|
IStaticResourceBuilder<R> |
file(String url)
Start the creation of a
static resource file. |
IRouteBuilder<R> |
GET(String path)
Starts the creation of a
GET route. |
List<IRoute<R>> |
getGlobalAfterFiltersRoutes()
Gets the global "after" filters.
|
List<IRoute<R>> |
getGlobalBeforeFiltersRoutes()
Gets the global "before" filters.
|
List<IRoute<R>> |
getMainRoutes()
Gets the main routes.
|
IRoute<R> |
getRoute(String routeId)
Gets a route using its
routeId. |
Map<String,String> |
getRouteParamPatternAliases()
The path patterns' aliases.
|
IRouteBuilder<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(IHandler<R> handler)
Creates a route considered during an "Not Found" routing process.
|
void |
notFound(String path,
IHandler<R> handler)
Creates a route considered during an "Not Found" routing process.
|
IRouteBuilder<R> |
OPTIONS(String path)
Starts the creation of a
OPTIONS route. |
IRouteBuilder<R> |
PATCH(String path)
Starts the creation of a
PATCH route. |
IRouteBuilder<R> |
POST(String path)
Starts the creation of a
POST route. |
IRouteBuilder<R> |
PUT(String path)
Starts the creation of a
PUT route. |
void |
removeAllRoutes()
Removes all routes.
|
void |
removeRoute(String routeId)
Removes a route using its
routeId. |
IRoutingResult<R> |
route(R requestContext)
Find the route to use to handle the current request.
|
IRoutingResult<R> |
route(R requestContext,
RoutingType routingType)
Find the route to use to handle the current request, given the
specified routing type.
|
IRouteBuilder<R> |
SOME(String path,
HttpMethod... httpMethods)
Starts the creation of a route matching the specified
HTTP methods.
|
IRouteBuilder<R> |
SOME(String path,
Set<HttpMethod> httpMethods)
Starts the creation of a route matching the specified
HTTP methods.
|
IRouteBuilder<R> |
TRACE(String path)
Starts the creation of a
TRACE route. |
IWebsocketRouteBuilder<R,W> |
websocket(String path)
Starts the creation of a
Websocket route. |
static final String DEFAULT_ROUTE_PATH
IRouteBuilder<R> GET(String path)
GET route.IRouteBuilder<R> POST(String path)
POST route.IRouteBuilder<R> PUT(String path)
PUT route.IRouteBuilder<R> DELETE(String path)
DELETE route.IRouteBuilder<R> OPTIONS(String path)
OPTIONS route.IRouteBuilder<R> TRACE(String path)
TRACE route.IRouteBuilder<R> HEAD(String path)
HEAD route.IRouteBuilder<R> PATCH(String path)
PATCH route.IRouteBuilder<R> ALL(String path)
IRouteBuilder<R> SOME(String path, Set<HttpMethod> httpMethods)
IRouteBuilder<R> SOME(String path, HttpMethod... httpMethods)
void before(IHandler<R> handler)
ALL("/*{path}").pos(-1).save(handler)
and with the Routing types as returned by
ISpincastRouterConfig#getFilterDefaultRoutingTypes()void before(String path, IHandler<R> handler)
ALL(path).pos(-1).save(handler)
and with the Routing types as returned by
ISpincastRouterConfig#getFilterDefaultRoutingTypes()void after(IHandler<R> handler)
ALL("/*{path}").pos(1).save(handler)
and with the Routing types as returned by
ISpincastRouterConfig#getFilterDefaultRoutingTypes()void after(String path, IHandler<R> handler)
ALL(path).pos(1).save(handler)
and with the Routing types as returned by
ISpincastRouterConfig#getFilterDefaultRoutingTypes()void beforeAndAfter(IHandler<R> handler)
ALL("/*{path}").pos(-1).save(handler)
and
ALL("/*{path}").pos(1).save(handler)
and with the Routing types as returned by
ISpincastRouterConfig#getFilterDefaultRoutingTypes()void beforeAndAfter(String path, IHandler<R> handler)
ALL(path).pos(-1).save(handler)
and
ALL(path).pos(1).save(handler)
and with the Routing types as returned by
ISpincastRouterConfig#getFilterDefaultRoutingTypes()void exception(IHandler<R> handler)
ALL("/*{path}").exception().save(handler)void exception(String path, IHandler<R> handler)
ALL(path).exception().save(handler)void notFound(IHandler<R> handler)
ALL("/*{path}").notFound().save(handler)void notFound(String path, IHandler<R> handler)
ALL(path).notFound().save(handler)IStaticResourceBuilder<R> file(String url)
static resource file.
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.IStaticResourceBuilder<R> dir(String url)
static resource 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()
ISpincastFilters#cors(R context)void cors(Set<String> allowedOrigins)
ISpincastFilters#cors(R context,
Set<String> allowedOrigins)void cors(Set<String> allowedOrigins, Set<String> extraHeadersAllowedToBeRead)
ISpincastFilters#cors(R context,
Set<String> allowedOrigins,
Set<String> extraHeadersAllowedToBeReadt)void cors(Set<String> allowedOrigins, Set<String> extraHeadersAllowedToBeRead, Set<String> extraHeadersAllowedToBeSent)
ISpincastFilters#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)
ISpincastFilters#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)
ISpincastFilters#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)
ISpincastFilters#cors(R context,
Set<String> allowedOrigins,
Set<String> extraHeadersAllowedToBeRead,
Set<String> extraHeadersAllowedToBeSent,
boolean allowCookies,
Set<HttpMethod> allowedMethods,
int maxAgeInSeconds)void cors(String path)
ISpincastFilters#cors(R context)void cors(String path, Set<String> allowedOrigins)
ISpincastFilters#cors(R context,
Set<String> allowedOrigins)void cors(String path, Set<String> allowedOrigins, Set<String> extraHeadersAllowedToBeRead)
ISpincastFilters#cors(R context,
Set<String> allowedOrigins,
Set<String> extraHeadersAllowedToBeRead)void cors(String path, Set<String> allowedOrigins, Set<String> extraHeadersAllowedToBeRead, Set<String> extraHeadersAllowedToBeSent)
ISpincastFilters#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)
ISpincastFilters#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)
ISpincastFilters#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)
ISpincastFilters#cors(R context,
Set<String> allowedOrigins,
Set<String> extraHeadersAllowedToBeRead,
Set<String> extraHeadersAllowedToBeSent,
boolean allowCookies,
Set<HttpMethod> allowedMethods,
int maxAgeInSeconds)void addStaticResource(IStaticResource<R> staticResource)
static resource route, directly.IRoutingResult<R> route(R requestContext)
null if no route matches.IRoutingResult<R> route(R requestContext, RoutingType routingType)
null if no route matches.void removeAllRoutes()
void removeRoute(String routeId)
routeId.List<IRoute<R>> getGlobalBeforeFiltersRoutes()
List<IRoute<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)
IWebsocketRouteBuilder<R,W> websocket(String path)
Websocket route.void addWebsocketRoute(IWebsocketRoute<R,W> websocketRoute)
Copyright © 2016. All rights reserved.