Interface Router<R extends RequestContext<?>,W extends WebsocketContext<?>>
- All Known Subinterfaces:
AppRouter
,AppRouter
,DefaultRouter
- All Known Implementing Classes:
AppRouterDefault
,AppRouterDefault
,DefaultRouterDefault
,SpincastRouter
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
The default path used when Spincast creates routes by itself. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds a route, directly.void
addRouteParamPatternAlias
(String alias, String pattern) Adds an alias for a path pattern.void
addStaticResource
(StaticResource<R> staticResource) Adds astatic resource
route, directly.void
addWebsocketRoute
(WebsocketRoute<R, W> websocketRoute) Adds a Websocket route, directly.ALL()
Starts the creation of a route matching any HTTP method, and on any 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
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
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
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!)void
Enables Cross-Origin Resource Sharing (Cors) on matching requests (except the static resources, for whom cors has to be activated directly!)void
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!)DELETE()
Starts the creation of aDELETE
route, for all path.Starts the creation of aDELETE
route.Start the creation of astatic resource
directory.void
Creates a route considered during an "Exception" routing process.void
Creates a route considered during an "Exception" routing process.Start the creation of astatic resource
file.GET()
Starts the creation of aGET
route, for all path.Starts the creation of aGET
route.Gets the global "after" filters.Gets the global "before" filters.Gets the main routes.Gets a route using itsrouteId
.The path patterns' aliases.HEAD()
Starts the creation of aHEAD
route, for all path.Starts the creation of aHEAD
route.void
Creates HTTP authentication protection (realm) for the specified path prefix.methods
(String path, Set<HttpMethod> httpMethods) Starts the creation of a route matching the specified HTTP methods.methods
(String path, HttpMethod... httpMethods) Starts the creation of a route matching the specified HTTP methods.methods
(Set<HttpMethod> httpMethods) Starts the creation of a route matching the specified HTTP methods and on any path.methods
(HttpMethod... httpMethods) Starts the creation of a route matching the specified HTTP methods and on any path.void
Creates a route considered during an "Not Found" routing process.void
Creates a route considered during an "Not Found" routing process.OPTIONS()
Starts the creation of aOPTIONS
route, for all path.Starts the creation of aOPTIONS
route.PATCH()
Starts the creation of aPATCH
route, for all path.Starts the creation of aPATCH
route.POST()
Starts the creation of aPOST
route, for all path.Starts the creation of aPOST
route.PUT()
Starts the creation of aPUT
route, for all path.Starts the creation of aPUT
route.Starts the creation of a redirection rule.void
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 itsrouteId
.Find the route to use to handle the current request.route
(R requestContext, RoutingType routingType) Find the route to use to handle the current request, given the specified routing type.TRACE()
Starts the creation of aTRACE
route, for all path.Starts the creation of aTRACE
route, at the specified position.Starts the creation of aWebsocket route
.
-
Field Details
-
DEFAULT_ROUTE_PATH
The default path used when Spincast creates routes by itself.- See Also:
-
-
Method Details
-
GET
RouteBuilder<R> GET()Starts the creation of aGET
route, for all path. Same asGET("/*{path}")
. -
GET
Starts the creation of aGET
route. -
POST
RouteBuilder<R> POST()Starts the creation of aPOST
route, for all path. Same asPOST("/*{path}")
. -
POST
Starts the creation of aPOST
route. -
PUT
RouteBuilder<R> PUT()Starts the creation of aPUT
route, for all path. Same asPUT("/*{path}")
. -
PUT
Starts the creation of aPUT
route. -
DELETE
RouteBuilder<R> DELETE()Starts the creation of aDELETE
route, for all path. Same asDELETE("/*{path}")
. -
DELETE
Starts the creation of aDELETE
route. -
OPTIONS
RouteBuilder<R> OPTIONS()Starts the creation of aOPTIONS
route, for all path. Same asOPTIONS("/*{path}")
. -
OPTIONS
Starts the creation of aOPTIONS
route. -
TRACE
RouteBuilder<R> TRACE()Starts the creation of aTRACE
route, for all path. Same asTRACE("/*{path}")
. -
TRACE
Starts the creation of aTRACE
route, at the specified position. -
HEAD
RouteBuilder<R> HEAD()Starts the creation of aHEAD
route, for all path. Same asHEAD("/*{path}")
. -
HEAD
Starts the creation of aHEAD
route. -
PATCH
RouteBuilder<R> PATCH()Starts the creation of aPATCH
route, for all path. Same asPATCH("/*{path}")
. -
PATCH
Starts the creation of aPATCH
route. -
ALL
RouteBuilder<R> ALL()Starts the creation of a route matching any HTTP method, and on any path. Same asALL("/*{path}")
. -
ALL
Starts the creation of a route matching any HTTP method. -
methods
Starts the creation of a route matching the specified HTTP methods and on any path. Same asmethods("/*{path}", httpMethods)
. -
methods
Starts the creation of a route matching the specified HTTP methods. -
methods
Starts the creation of a route matching the specified HTTP methods and on any path. Same asmethods("/*{path}", httpMethods)
. -
methods
Starts the creation of a route matching the specified HTTP methods. -
exception
Creates a route considered during an "Exception" routing process.Synonym of :
ALL("/*{path}").exception().handle(handler)
-
exception
Creates a route considered during an "Exception" routing process.Synonym of :
ALL(path).exception().handle(handler)
-
notFound
Creates a route considered during an "Not Found" routing process.Synonym of :
ALL("/*{path}").notFound().handle(handler)
-
notFound
Creates a route considered during an "Not Found" routing process.Synonym of :
ALL(path).notFound().handle(handler)
-
file
Start the creation of astatic resource
file.Only a
GET
or aHEAD
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.
- Parameters:
url
- The url which will trigger the output of this static resource.
-
dir
Start the creation of astatic resource
directory.Only a
GET
or aHEAD
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.
- Parameters:
url
- The url which will trigger the output of this static resource.
-
cors
void cors()Enables Cross-Origin Resource Sharing (Cors) on all matching requests (except the static resources, for whom cors has to be activated directly!)- See Also:
-
SpincastFilters#cors(R context)
-
cors
Enables Cross-Origin Resource Sharing (Cors) on matching requests (except the static resources, for whom cors has to be activated directly!)- See Also:
-
SpincastFilters#cors(R context, Set<String> allowedOrigins)
-
cors
Enables Cross-Origin Resource Sharing (Cors) on matching requests (except the static resources, for whom cors has to be activated directly!)- See Also:
-
SpincastFilters#cors(R context, Set<String> allowedOrigins, Set<String> extraHeadersAllowedToBeReadt)
-
cors
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!)- See Also:
-
SpincastFilters#cors(R context, Set<String> allowedOrigins, Set<String> extraHeadersAllowedToBeRead, Set<String> extraHeadersAllowedToBeSent)
-
cors
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!)- See Also:
-
SpincastFilters#cors(R context, Set<String> allowedOrigins, Set<String> extraHeadersAllowedToBeRead, Set<String> extraHeadersAllowedToBeSent, boolean allowCookies)
-
cors
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!)- See Also:
-
SpincastFilters#cors(R context, Set<String> allowedOrigins, Set<String> extraHeadersAllowedToBeRead, Set<String> extraHeadersAllowedToBeSent, boolean allowCookies, Set<HttpMethod> allowedMethods)
-
cors
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!)- See Also:
-
SpincastFilters#cors(R context, Set<String> allowedOrigins, Set<String> extraHeadersAllowedToBeRead, Set<String> extraHeadersAllowedToBeSent, boolean allowCookies, Set<HttpMethod> allowedMethods, int maxAgeInSeconds)
-
cors
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!)- See Also:
-
SpincastFilters#cors(R context)
-
cors
Enables Cross-Origin Resource Sharing (Cors) on requests matching the specified path (except the static resources, for whom cors has to be activated directly!)- See Also:
-
SpincastFilters#cors(R context, Set<String> allowedOrigins)
-
cors
Enables Cross-Origin Resource Sharing (Cors) on requests matching the specified path (except the static resources, for whom cors has to be activated directly!)- See Also:
-
SpincastFilters#cors(R context, Set<String> allowedOrigins, Set<String> extraHeadersAllowedToBeRead)
-
cors
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!)- See Also:
-
SpincastFilters#cors(R context, Set<String> allowedOrigins, Set<String> extraHeadersAllowedToBeRead, Set<String> extraHeadersAllowedToBeSent)
-
cors
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!)- See Also:
-
SpincastFilters#cors(R context, Set<String> allowedOrigins, Set<String> extraHeadersAllowedToBeRead, Set<String> extraHeadersAllowedToBeSent, boolean allowCookies)
-
cors
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!)- See Also:
-
SpincastFilters#cors(R context, Set<String> allowedOrigins, Set<String> extraHeadersAllowedToBeRead, Set<String> extraHeadersAllowedToBeSent, boolean allowCookies, Set<HttpMethod> allowedMethods)
-
cors
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!)- See Also:
-
SpincastFilters#cors(R context, Set<String> allowedOrigins, Set<String> extraHeadersAllowedToBeRead, Set<String> extraHeadersAllowedToBeSent, boolean allowCookies, Set<HttpMethod> allowedMethods, int maxAgeInSeconds)
-
addStaticResource
Adds astatic resource
route, directly. -
route
Find the route to use to handle the current request. The result contains all handlers to use.- Returns:
- the routing result or
null
if no route matches.
-
route
Find the route to use to handle the current request, given the specified routing type. The result contains all handlers to use.- Returns:
- the routing result or
null
if no route matches.
-
addRoute
Adds a route, directly. -
removeAllRoutes
void removeAllRoutes()Removes all application routes (not the ones added by Spincast and plugins). -
removeAllRoutes
void removeAllRoutes(boolean removeSpincastAndPluginsRoutesToo) Removes all routes.- Parameters:
removeSpincastAndPluginsRoutesToo
- Should the routes added by Spincast and plugins be removed too?
-
removeRoute
Removes a route using itsrouteId
. -
getRoute
Gets a route using itsrouteId
. -
getGlobalBeforeFiltersRoutes
Gets the global "before" filters. -
getMainRoutes
Gets the main routes. -
getGlobalAfterFiltersRoutes
Gets the global "after" filters. -
addRouteParamPatternAlias
Adds an alias for a path pattern. For example, the path of a route may be"/${param1:<XXX>}"
: here "XXX" is the alias for the regular expression pattern to use. -
getRouteParamPatternAliases
The path patterns' aliases. The map is mutable. -
httpAuth
Creates HTTP authentication protection (realm) for the specified path prefix. -
websocket
Starts the creation of aWebsocket route
. -
addWebsocketRoute
Adds a Websocket route, directly. -
redirect
Starts the creation of a redirection rule.Redirecttion rule are ran at position "0", as a regular route. Therefore the order in which they are added to the router is very important! As soon as a redirect rule matches, the request is redirected.
- Parameters:
oldPath
- The old path that needs to be redirected.
-