public.javadoc.org.spincast.core.routing.Router.html Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of spincast-website Show documentation
Show all versions of spincast-website Show documentation
Source code for the https://www.spincast.org website.
Router (org.spincast:spincast-framework 1.0.0 API)
org.spincast.core.routing
Interface Router<R extends RequestContext<?>,W extends WebsocketContext<?>>
-
- All Known Subinterfaces:
- DefaultRouter
- All Known Implementing Classes:
- DefaultRouterDefault, SpincastRouter
public interface Router<R extends RequestContext<?>,W extends WebsocketContext<?>>
The router.
-
-
Field Summary
Fields
Modifier and Type
Field and Description
static String
DEFAULT_ROUTE_PATH
The default path used when Spincast creates routes by
itself.
-
Method Summary
All Methods Instance Methods Abstract Methods
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
.
-
-
Field Detail
-
DEFAULT_ROUTE_PATH
static final String DEFAULT_ROUTE_PATH
The default path used when Spincast creates routes by
itself.
- See Also:
- Constant Field Values
-
Method Detail
-
GET
RouteBuilder<R> GET()
Starts the creation of a GET
route,
for all path. Same as GET("/*{path}")
.
-
GET
RouteBuilder<R> GET(String path)
Starts the creation of a GET
route.
-
POST
RouteBuilder<R> POST()
Starts the creation of a POST
route,
for all path. Same as POST("/*{path}")
.
-
POST
RouteBuilder<R> POST(String path)
Starts the creation of a POST
route.
-
PUT
RouteBuilder<R> PUT()
Starts the creation of a PUT
route,
for all path. Same as PUT("/*{path}")
.
-
PUT
RouteBuilder<R> PUT(String path)
Starts the creation of a PUT
route.
-
DELETE
RouteBuilder<R> DELETE()
Starts the creation of a DELETE
route,
for all path. Same as DELETE("/*{path}")
.
-
DELETE
RouteBuilder<R> DELETE(String path)
Starts the creation of a DELETE
route.
-
OPTIONS
RouteBuilder<R> OPTIONS()
Starts the creation of a OPTIONS
route,
for all path. Same as OPTIONS("/*{path}")
.
-
OPTIONS
RouteBuilder<R> OPTIONS(String path)
Starts the creation of a OPTIONS
route.
-
TRACE
RouteBuilder<R> TRACE()
Starts the creation of a TRACE
route,
for all path. Same as TRACE("/*{path}")
.
-
TRACE
RouteBuilder<R> TRACE(String path)
Starts the creation of a TRACE
route,
at the specified position.
-
HEAD
RouteBuilder<R> HEAD()
Starts the creation of a HEAD
route,
for all path. Same as HEAD("/*{path}")
.
-
HEAD
RouteBuilder<R> HEAD(String path)
Starts the creation of a HEAD
route.
-
PATCH
RouteBuilder<R> PATCH()
Starts the creation of a PATCH
route,
for all path. Same as PATCH("/*{path}")
.
-
PATCH
RouteBuilder<R> PATCH(String path)
Starts the creation of a PATCH
route.
-
ALL
RouteBuilder<R> ALL()
Starts the creation of a route matching any HTTP method,
and on any path. Same as ALL("/*{path}")
.
-
ALL
RouteBuilder<R> ALL(String path)
Starts the creation of a route matching any HTTP method.
-
methods
RouteBuilder<R> methods(Set<HttpMethod> httpMethods)
Starts the creation of a route matching the specified
HTTP methods and on any path. Same as
methods("/*{path}", httpMethods)
.
-
methods
RouteBuilder<R> methods(String path,
Set<HttpMethod> httpMethods)
Starts the creation of a route matching the specified
HTTP methods.
-
methods
RouteBuilder<R> methods(HttpMethod... httpMethods)
Starts the creation of a route matching the specified
HTTP methods and on any path. Same as
methods("/*{path}", httpMethods)
.
-
methods
RouteBuilder<R> methods(String path,
HttpMethod... httpMethods)
Starts the creation of a route matching the specified
HTTP methods.
-
exception
void exception(Handler<R> handler)
Creates a route considered during an "Exception" routing process.
Synonym of :
ALL("/*{path}").exception().handle(handler)
-
exception
void exception(String path,
Handler<R> handler)
Creates a route considered during an "Exception" routing process.
Synonym of :
ALL(path).exception().handle(handler)
-
notFound
void notFound(Handler<R> handler)
Creates a route considered during an "Not Found" routing process.
Synonym of :
ALL("/*{path}").notFound().handle(handler)
-
notFound
void notFound(String path,
Handler<R> handler)
Creates a route considered during an "Not Found" routing process.
Synonym of :
ALL(path).notFound().handle(handler)
-
file
StaticResourceBuilder<R> file(String url)
Start the creation of a 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.
- Parameters:
url
- The url which will trigger the output of this
static resource.
-
dir
StaticResourceBuilder<R> dir(String url)
Start the creation of a 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.
- 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
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!)
- See Also:
SpincastFilters#cors(R context,
Set<String> allowedOrigins)
-
cors
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!)
- 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
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!)
- See Also:
SpincastFilters#cors(R context)
-
cors
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!)
- See Also:
SpincastFilters#cors(R context,
Set<String> allowedOrigins)
-
cors
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!)
- 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
void addStaticResource(StaticResource<R> staticResource)
Adds a static resource
route, directly.
-
route
RoutingResult<R> route(R requestContext)
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
RoutingResult<R> route(R requestContext,
RoutingType routingType)
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.
-
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
void removeRoute(String routeId)
Removes a route using its routeId
.
-
getGlobalBeforeFiltersRoutes
List<Route<R>> getGlobalBeforeFiltersRoutes()
Gets the global "before" filters.
-
getGlobalAfterFiltersRoutes
List<Route<R>> getGlobalAfterFiltersRoutes()
Gets the global "after" filters.
-
addRouteParamPatternAlias
void addRouteParamPatternAlias(String alias,
String pattern)
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
Map<String,String> getRouteParamPatternAliases()
The path patterns' aliases.
Themap is mutable.
-
httpAuth
void httpAuth(String pathPrefix,
String realmName)
Creates HTTP authentication protection (realm) for the
specified path prefix.
-
websocket
WebsocketRouteBuilder<R,W> websocket(String path)
Starts the creation of a Websocket route
.
-
addWebsocketRoute
void addWebsocketRoute(WebsocketRoute<R,W> websocketRoute)
Adds a Websocket route, directly.
-
redirect
RedirectRuleBuilder redirect(String oldPath)
Starts the creation of a redirection rule.
- Parameters:
oldPath
- The old path that needs to be redirected.
Copyright © 2019. All rights reserved.