public.javadoc.org.spincast.plugins.routing.SpincastRouter.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.
SpincastRouter (org.spincast:spincast-framework 1.13.0 API)
org.spincast.plugins.routing
Class SpincastRouter<R extends RequestContext<?>,W extends WebsocketContext<?>>
- java.lang.Object
-
- org.spincast.plugins.routing.SpincastRouter<R,W>
-
- All Implemented Interfaces:
- Router<R,W>
- Direct Known Subclasses:
- DefaultRouterDefault
public class SpincastRouter<R extends RequestContext<?>,W extends WebsocketContext<?>>
extends Object
implements Router<R,W>
Spincast router
-
-
Field Summary
Fields
Modifier and Type
Field and Description
protected static org.slf4j.Logger
logger
-
Fields inherited from interface org.spincast.core.routing.Router
DEFAULT_ROUTE_PATH
-
Constructor Summary
Constructors
Constructor and Description
SpincastRouter(SpincastRouterDeps<R,W> spincastRouterDeps)
-
Method Summary
All Methods Instance Methods Concrete Methods
Modifier and Type
Method and Description
protected void
addDefaultFilters()
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!)
protected RouteHandlerMatch<R>
createHandlerMatchForBeforeOrAfterFilter(RouteHandlerMatch<R> mainRouteHandlerMatch,
Handler<R> beforeOrAfterMethod,
int position)
Creates a new match for a "before" or "after" handler specific
to a route.
protected Route<R>
createHttpRouteFromWebsocketRoute(WebsocketRoute<R,W> websocketRoute)
protected RouteHandlerMatch<R>
createNoMatchingParamsHandlerMatch(Route<R> route,
String id,
Handler<R> handler,
int position)
Creates an handler match with no matching params.
protected List<RouteHandlerMatch<R>>
createRegularHandlerMatches(RoutingType routingType,
Route<R> route,
HttpMethod httpMethod,
List<String> acceptedContentTypes,
URL url,
int position)
Get the matches (filters and main handle) if the route matches the URL and
HTTP method, or returns NULL otherwise.
protected RoutingResult<R>
createRoutingResult(List<RouteHandlerMatch<R>> routeHandlerMatches)
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.
protected Dictionary
getDictionary()
protected Map<Integer,List<Route<R>>>
getGlobalAfterFiltersPerPosition()
List<Route<R>>
getGlobalAfterFiltersRoutes()
Gets the global "after" filters.
protected Map<Integer,List<Route<R>>>
getGlobalBeforeFiltersPerPosition()
List<Route<R>>
getGlobalBeforeFiltersRoutes()
Gets the global "before" filters.
List<Route<R>>
getMainRoutes()
Gets the main routes.
protected Pattern
getPattern(String patternStr)
protected String
getPatternFromAlias(String alias)
Get a path pattern from its alias.
protected RedirectRuleBuilderFactory<R,W>
getRedirectRuleBuilderFactory()
Route<R>
getRoute(String routeId)
Gets a route using its routeId
.
protected RouteBuilderFactory<R,W>
getRouteBuilderFactory()
protected RouteFactory<R>
getRouteFactory()
protected RouteHandlerMatchFactory<R>
getRouteHandlerMatchFactory()
Map<String,String>
getRouteParamPatternAliases()
The path patterns' aliases.
protected Server
getServer()
protected SpincastConfig
getSpincastConfig()
protected SpincastFilters<R>
getSpincastFilters()
protected SpincastRouterConfig
getSpincastRouterConfig()
protected SpincastRoutingUtils
getSpincastRoutingUtils()
protected StaticResourceBuilderFactory<R,W>
getStaticResourceBuilderFactory()
protected StaticResourceFactory<R>
getStaticResourceFactory()
protected WebsocketRouteBuilderFactory<R,W>
getWebsocketRouteBuilderFactory()
protected WebsocketRouteHandlerFactory<R,W>
getWebsocketRouteHandlerFactory()
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.
protected void
init()
protected boolean
isCreateStaticResourceOnDisk()
protected boolean
isMustSkipResourceRequest(Route<R> mainRoute,
Route<R> filterRoute)
protected boolean
isRouteMatchAcceptedContentType(Route<R> route,
List<String> requestContentTypes)
protected boolean
isRouteMatchHttpMethod(Route<R> route,
HttpMethod httpMethod)
Validate if a route matches the given HTTP method.
protected boolean
isRoutingTypeMatch(RoutingType routingType,
Route<R> route)
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<R,W>
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.
RoutingResult<R>
route(R requestContext,
String fullUrl,
RoutingType routingType)
protected boolean
startsWithAnyOf(String id,
Set<String> prefixes)
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.
protected void
validateId(String id)
protected void
validatePath(String path)
Validate the path of a route.
protected Map<String,String>
validatePath(String routePath,
URL url)
Validate if url matches the path of the route and if so, returns the
parsed parameters, if any.
protected void
validation()
WebsocketRouteBuilder<R,W>
websocket(String path)
Starts the creation of a Websocket route
.
-
-
Constructor Detail
-
SpincastRouter
@Inject
public SpincastRouter(SpincastRouterDeps<R,W> spincastRouterDeps)
-
Method Detail
-
init
@Inject
protected void init()
-
validation
protected void validation()
-
addDefaultFilters
protected void addDefaultFilters()
-
getSpincastRouterConfig
protected SpincastRouterConfig getSpincastRouterConfig()
-
getRouteFactory
protected RouteFactory<R> getRouteFactory()
-
getSpincastConfig
protected SpincastConfig getSpincastConfig()
-
getDictionary
protected Dictionary getDictionary()
-
getServer
protected Server getServer()
-
getSpincastFilters
protected SpincastFilters<R> getSpincastFilters()
-
getRouteBuilderFactory
protected RouteBuilderFactory<R,W> getRouteBuilderFactory()
-
getRedirectRuleBuilderFactory
protected RedirectRuleBuilderFactory<R,W> getRedirectRuleBuilderFactory()
-
getWebsocketRouteBuilderFactory
protected WebsocketRouteBuilderFactory<R,W> getWebsocketRouteBuilderFactory()
-
getWebsocketRouteHandlerFactory
protected WebsocketRouteHandlerFactory<R,W> getWebsocketRouteHandlerFactory()
-
getStaticResourceBuilderFactory
protected StaticResourceBuilderFactory<R,W> getStaticResourceBuilderFactory()
-
getRouteHandlerMatchFactory
protected RouteHandlerMatchFactory<R> getRouteHandlerMatchFactory()
-
getStaticResourceFactory
protected StaticResourceFactory<R> getStaticResourceFactory()
-
getSpincastRoutingUtils
protected SpincastRoutingUtils getSpincastRoutingUtils()
-
getRouteParamPatternAliases
public Map<String,String> getRouteParamPatternAliases()
Description copied from interface: Router
The path patterns' aliases.
The map is mutable.
- Specified by:
getRouteParamPatternAliases
in interface Router<R extends RequestContext<?>,W extends WebsocketContext<?>>
-
getRoute
public Route<R> getRoute(String routeId)
Description copied from interface: Router
Gets a route using its routeId
.
- Specified by:
getRoute
in interface Router<R extends RequestContext<?>,W extends WebsocketContext<?>>
-
getGlobalBeforeFiltersPerPosition
protected Map<Integer,List<Route<R>>> getGlobalBeforeFiltersPerPosition()
-
getGlobalBeforeFiltersRoutes
public List<Route<R>> getGlobalBeforeFiltersRoutes()
Description copied from interface: Router
Gets the global "before" filters.
- Specified by:
getGlobalBeforeFiltersRoutes
in interface Router<R extends RequestContext<?>,W extends WebsocketContext<?>>
-
getGlobalAfterFiltersPerPosition
protected Map<Integer,List<Route<R>>> getGlobalAfterFiltersPerPosition()
-
getGlobalAfterFiltersRoutes
public List<Route<R>> getGlobalAfterFiltersRoutes()
Description copied from interface: Router
Gets the global "after" filters.
- Specified by:
getGlobalAfterFiltersRoutes
in interface Router<R extends RequestContext<?>,W extends WebsocketContext<?>>
-
getMainRoutes
public List<Route<R>> getMainRoutes()
Description copied from interface: Router
Gets the main routes.
- Specified by:
getMainRoutes
in interface Router<R extends RequestContext<?>,W extends WebsocketContext<?>>
-
addRoute
public void addRoute(Route<R> route)
Description copied from interface: Router
Adds a route, directly.
- Specified by:
addRoute
in interface Router<R extends RequestContext<?>,W extends WebsocketContext<?>>
-
validateId
protected void validateId(String id)
-
validatePath
protected void validatePath(String path)
Validate the path of a route.
Throws an exception if not valide.
-
removeAllRoutes
public void removeAllRoutes()
Description copied from interface: Router
Removes all application routes (not the
ones added by Spincast and plugins).
- Specified by:
removeAllRoutes
in interface Router<R extends RequestContext<?>,W extends WebsocketContext<?>>
-
removeAllRoutes
public void removeAllRoutes(boolean removeSpincastAndPluginsRoutesToo)
Description copied from interface: Router
Removes all routes.
- Specified by:
removeAllRoutes
in interface Router<R extends RequestContext<?>,W extends WebsocketContext<?>>
- Parameters:
removeSpincastAndPluginsRoutesToo
- Should the routes added by
Spincast and plugins be removed too?
-
removeRoute
public void removeRoute(String routeId)
Description copied from interface: Router
Removes a route using its routeId
.
- Specified by:
removeRoute
in interface Router<R extends RequestContext<?>,W extends WebsocketContext<?>>
-
route
public RoutingResult<R> route(R requestContext)
Description copied from interface: Router
Find the route to use to handle the current request. The result
contains all handlers to use.
- Specified by:
route
in interface Router<R extends RequestContext<?>,W extends WebsocketContext<?>>
- Returns:
- the routing result or
null
if no route matches.
-
route
public RoutingResult<R> route(R requestContext,
RoutingType routingType)
Description copied from interface: Router
Find the route to use to handle the current request, given the
specified routing type. The result contains all handlers to use.
- Specified by:
route
in interface Router<R extends RequestContext<?>,W extends WebsocketContext<?>>
- Returns:
- the routing result or
null
if no route matches.
-
route
public RoutingResult<R> route(R requestContext,
String fullUrl,
RoutingType routingType)
-
isRoutingTypeMatch
protected boolean isRoutingTypeMatch(RoutingType routingType,
Route<R> route)
-
isMustSkipResourceRequest
protected boolean isMustSkipResourceRequest(Route<R> mainRoute,
Route<R> filterRoute)
-
createRoutingResult
protected RoutingResult<R> createRoutingResult(List<RouteHandlerMatch<R>> routeHandlerMatches)
-
createRegularHandlerMatches
protected List<RouteHandlerMatch<R>> createRegularHandlerMatches(RoutingType routingType,
Route<R> route,
HttpMethod httpMethod,
List<String> acceptedContentTypes,
URL url,
int position)
Get the matches (filters and main handle) if the route matches the URL and
HTTP method, or returns NULL otherwise.
-
isRouteMatchAcceptedContentType
protected boolean isRouteMatchAcceptedContentType(Route<R> route,
List<String> requestContentTypes)
-
createNoMatchingParamsHandlerMatch
protected RouteHandlerMatch<R> createNoMatchingParamsHandlerMatch(Route<R> route,
String id,
Handler<R> handler,
int position)
Creates an handler match with no matching params.
-
createHandlerMatchForBeforeOrAfterFilter
protected RouteHandlerMatch<R> createHandlerMatchForBeforeOrAfterFilter(RouteHandlerMatch<R> mainRouteHandlerMatch,
Handler<R> beforeOrAfterMethod,
int position)
Creates a new match for a "before" or "after" handler specific
to a route. THis measn keeping the same informations as the
main handler.
-
isRouteMatchHttpMethod
protected boolean isRouteMatchHttpMethod(Route<R> route,
HttpMethod httpMethod)
Validate if a route matches the given HTTP method.
-
validatePath
protected Map<String,String> validatePath(String routePath,
URL url)
Validate if url matches the path of the route and if so, returns the
parsed parameters, if any.
Returns NULL if there is no match.
-
getPatternFromAlias
protected String getPatternFromAlias(String alias)
Get a path pattern from its alias.
- Returns:
- the pattern or NULL if not found.
-
addRouteParamPatternAlias
public void addRouteParamPatternAlias(String alias,
String pattern)
Description copied from interface: Router
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.
- Specified by:
addRouteParamPatternAlias
in interface Router<R extends RequestContext<?>,W extends WebsocketContext<?>>
-
GET
public RouteBuilder<R> GET()
Description copied from interface: Router
Starts the creation of a GET
route,
for all path. Same as GET("/*{path}")
.
- Specified by:
GET
in interface Router<R extends RequestContext<?>,W extends WebsocketContext<?>>
-
GET
public RouteBuilder<R> GET(String path)
Description copied from interface: Router
Starts the creation of a GET
route.
- Specified by:
GET
in interface Router<R extends RequestContext<?>,W extends WebsocketContext<?>>
-
POST
public RouteBuilder<R> POST()
Description copied from interface: Router
Starts the creation of a POST
route,
for all path. Same as POST("/*{path}")
.
- Specified by:
POST
in interface Router<R extends RequestContext<?>,W extends WebsocketContext<?>>
-
POST
public RouteBuilder<R> POST(String path)
Description copied from interface: Router
Starts the creation of a POST
route.
- Specified by:
POST
in interface Router<R extends RequestContext<?>,W extends WebsocketContext<?>>
-
PUT
public RouteBuilder<R> PUT()
Description copied from interface: Router
Starts the creation of a PUT
route,
for all path. Same as PUT("/*{path}")
.
- Specified by:
PUT
in interface Router<R extends RequestContext<?>,W extends WebsocketContext<?>>
-
PUT
public RouteBuilder<R> PUT(String path)
Description copied from interface: Router
Starts the creation of a PUT
route.
- Specified by:
PUT
in interface Router<R extends RequestContext<?>,W extends WebsocketContext<?>>
-
DELETE
public RouteBuilder<R> DELETE()
Description copied from interface: Router
Starts the creation of a DELETE
route,
for all path. Same as DELETE("/*{path}")
.
- Specified by:
DELETE
in interface Router<R extends RequestContext<?>,W extends WebsocketContext<?>>
-
DELETE
public RouteBuilder<R> DELETE(String path)
Description copied from interface: Router
Starts the creation of a DELETE
route.
- Specified by:
DELETE
in interface Router<R extends RequestContext<?>,W extends WebsocketContext<?>>
-
OPTIONS
public RouteBuilder<R> OPTIONS()
Description copied from interface: Router
Starts the creation of a OPTIONS
route,
for all path. Same as OPTIONS("/*{path}")
.
- Specified by:
OPTIONS
in interface Router<R extends RequestContext<?>,W extends WebsocketContext<?>>
-
OPTIONS
public RouteBuilder<R> OPTIONS(String path)
Description copied from interface: Router
Starts the creation of a OPTIONS
route.
- Specified by:
OPTIONS
in interface Router<R extends RequestContext<?>,W extends WebsocketContext<?>>
-
TRACE
public RouteBuilder<R> TRACE()
Description copied from interface: Router
Starts the creation of a TRACE
route,
for all path. Same as TRACE("/*{path}")
.
- Specified by:
TRACE
in interface Router<R extends RequestContext<?>,W extends WebsocketContext<?>>
-
TRACE
public RouteBuilder<R> TRACE(String path)
Description copied from interface: Router
Starts the creation of a TRACE
route,
at the specified position.
- Specified by:
TRACE
in interface Router<R extends RequestContext<?>,W extends WebsocketContext<?>>
-
HEAD
public RouteBuilder<R> HEAD()
Description copied from interface: Router
Starts the creation of a HEAD
route,
for all path. Same as HEAD("/*{path}")
.
- Specified by:
HEAD
in interface Router<R extends RequestContext<?>,W extends WebsocketContext<?>>
-
HEAD
public RouteBuilder<R> HEAD(String path)
Description copied from interface: Router
Starts the creation of a HEAD
route.
- Specified by:
HEAD
in interface Router<R extends RequestContext<?>,W extends WebsocketContext<?>>
-
PATCH
public RouteBuilder<R> PATCH()
Description copied from interface: Router
Starts the creation of a PATCH
route,
for all path. Same as PATCH("/*{path}")
.
- Specified by:
PATCH
in interface Router<R extends RequestContext<?>,W extends WebsocketContext<?>>
-
PATCH
public RouteBuilder<R> PATCH(String path)
Description copied from interface: Router
Starts the creation of a PATCH
route.
- Specified by:
PATCH
in interface Router<R extends RequestContext<?>,W extends WebsocketContext<?>>
-
ALL
public RouteBuilder<R> ALL()
Description copied from interface: Router
Starts the creation of a route matching any HTTP method,
and on any path. Same as ALL("/*{path}")
.
- Specified by:
ALL
in interface Router<R extends RequestContext<?>,W extends WebsocketContext<?>>
-
ALL
public RouteBuilder<R> ALL(String path)
Description copied from interface: Router
Starts the creation of a route matching any HTTP method.
- Specified by:
ALL
in interface Router<R extends RequestContext<?>,W extends WebsocketContext<?>>
-
methods
public RouteBuilder<R> methods(HttpMethod... httpMethods)
Description copied from interface: Router
Starts the creation of a route matching the specified
HTTP methods and on any path. Same as
methods("/*{path}", httpMethods)
.
- Specified by:
methods
in interface Router<R extends RequestContext<?>,W extends WebsocketContext<?>>
-
methods
public RouteBuilder<R> methods(String path,
HttpMethod... httpMethods)
Description copied from interface: Router
Starts the creation of a route matching the specified
HTTP methods.
- Specified by:
methods
in interface Router<R extends RequestContext<?>,W extends WebsocketContext<?>>
-
methods
public RouteBuilder<R> methods(Set<HttpMethod> httpMethods)
Description copied from interface: Router
Starts the creation of a route matching the specified
HTTP methods and on any path. Same as
methods("/*{path}", httpMethods)
.
- Specified by:
methods
in interface Router<R extends RequestContext<?>,W extends WebsocketContext<?>>
-
methods
public RouteBuilder<R> methods(String path,
Set<HttpMethod> httpMethods)
Description copied from interface: Router
Starts the creation of a route matching the specified
HTTP methods.
- Specified by:
methods
in interface Router<R extends RequestContext<?>,W extends WebsocketContext<?>>
-
exception
public void exception(Handler<R> handler)
Description copied from interface: Router
Creates a route considered during an "Exception" routing process.
Synonym of :
ALL("/*{path}").exception().handle(handler)
- Specified by:
exception
in interface Router<R extends RequestContext<?>,W extends WebsocketContext<?>>
-
exception
public void exception(String path,
Handler<R> handler)
Description copied from interface: Router
Creates a route considered during an "Exception" routing process.
Synonym of :
ALL(path).exception().handle(handler)
- Specified by:
exception
in interface Router<R extends RequestContext<?>,W extends WebsocketContext<?>>
-
notFound
public void notFound(Handler<R> handler)
Description copied from interface: Router
Creates a route considered during an "Not Found" routing process.
Synonym of :
ALL("/*{path}").notFound().handle(handler)
- Specified by:
notFound
in interface Router<R extends RequestContext<?>,W extends WebsocketContext<?>>
-
notFound
public void notFound(String path,
Handler<R> handler)
Description copied from interface: Router
Creates a route considered during an "Not Found" routing process.
Synonym of :
ALL(path).notFound().handle(handler)
- Specified by:
notFound
in interface Router<R extends RequestContext<?>,W extends WebsocketContext<?>>
-
cors
public void cors()
Description copied from interface: Router
Enables Cross-Origin Resource Sharing (Cors) on all
matching requests (except the static resources,
for whom cors has to be activated directly!)
- Specified by:
cors
in interface Router<R extends RequestContext<?>,W extends WebsocketContext<?>>
- See Also:
SpincastFilters#cors(R context)
-
cors
public void cors(Set<String> allowedOrigins)
Description copied from interface: Router
Enables Cross-Origin Resource Sharing (Cors) on
matching requests (except the static resources,
for whom cors has to be activated directly!)
- Specified by:
cors
in interface Router<R extends RequestContext<?>,W extends WebsocketContext<?>>
- See Also:
SpincastFilters#cors(R context,
Set<String> allowedOrigins)
-
cors
public void cors(Set<String> allowedOrigins,
Set<String> extraHeadersAllowedToBeRead)
Description copied from interface: Router
Enables Cross-Origin Resource Sharing (Cors) on
matching requests (except the static resources,
for whom cors has to be activated directly!)
- Specified by:
cors
in interface Router<R extends RequestContext<?>,W extends WebsocketContext<?>>
- See Also:
SpincastFilters#cors(R context,
Set<String> allowedOrigins,
Set<String> extraHeadersAllowedToBeReadt)
-
cors
public void cors(Set<String> allowedOrigins,
Set<String> extraHeadersAllowedToBeRead,
Set<String> extraHeadersAllowedToBeSent)
Description copied from interface: Router
Enables Cross-Origin Resource Sharing (Cors) on
matching requests (except the static resources,
for whom cors has to be activated directly!)
- Specified by:
cors
in interface Router<R extends RequestContext<?>,W extends WebsocketContext<?>>
- See Also:
SpincastFilters#cors(R context,
Set<String> allowedOrigins,
Set<String> extraHeadersAllowedToBeRead,
Set<String> extraHeadersAllowedToBeSent)
-
cors
public void cors(Set<String> allowedOrigins,
Set<String> extraHeadersAllowedToBeRead,
Set<String> extraHeadersAllowedToBeSent,
boolean allowCookies)
Description copied from interface: Router
Enables Cross-Origin Resource Sharing (Cors) on
matching requests (except the static resources,
for whom cors has to be activated directly!)
- Specified by:
cors
in interface Router<R extends RequestContext<?>,W extends WebsocketContext<?>>
- See Also:
SpincastFilters#cors(R context,
Set<String> allowedOrigins,
Set<String> extraHeadersAllowedToBeRead,
Set<String> extraHeadersAllowedToBeSent,
boolean allowCookies)
-
cors
public void cors(Set<String> allowedOrigins,
Set<String> extraHeadersAllowedToBeRead,
Set<String> extraHeadersAllowedToBeSent,
boolean allowCookies,
Set<HttpMethod> allowedMethods)
Description copied from interface: Router
Enables Cross-Origin Resource Sharing (Cors) on
matching requests (except the static resources,
for whom cors has to be activated directly!)
- Specified by:
cors
in interface Router<R extends RequestContext<?>,W extends WebsocketContext<?>>
- See Also:
SpincastFilters#cors(R context,
Set<String> allowedOrigins,
Set<String> extraHeadersAllowedToBeRead,
Set<String> extraHeadersAllowedToBeSent,
boolean allowCookies,
Set<HttpMethod> allowedMethods)
-
cors
public void cors(Set<String> allowedOrigins,
Set<String> extraHeadersAllowedToBeRead,
Set<String> extraHeadersAllowedToBeSent,
boolean allowCookies,
Set<HttpMethod> allowedMethods,
int maxAgeInSeconds)
Description copied from interface: Router
Enables Cross-Origin Resource Sharing (Cors) on
matching requests (except the static resources,
for whom cors has to be activated directly!)
- Specified by:
cors
in interface Router<R extends RequestContext<?>,W extends WebsocketContext<?>>
- See Also:
SpincastFilters#cors(R context,
Set<String> allowedOrigins,
Set<String> extraHeadersAllowedToBeRead,
Set<String> extraHeadersAllowedToBeSent,
boolean allowCookies,
Set<HttpMethod> allowedMethods,
int maxAgeInSeconds)
-
cors
public void cors(String path)
Description copied from interface: Router
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!)
- Specified by:
cors
in interface Router<R extends RequestContext<?>,W extends WebsocketContext<?>>
- See Also:
SpincastFilters#cors(R context)
-
cors
public void cors(String path,
Set<String> allowedOrigins)
Description copied from interface: Router
Enables Cross-Origin Resource Sharing (Cors) on
requests matching the specified path (except the static resources,
for whom cors has to be activated directly!)
- Specified by:
cors
in interface Router<R extends RequestContext<?>,W extends WebsocketContext<?>>
- See Also:
SpincastFilters#cors(R context,
Set<String> allowedOrigins)
-
cors
public void cors(String path,
Set<String> allowedOrigins,
Set<String> extraHeadersAllowedToBeRead)
Description copied from interface: Router
Enables Cross-Origin Resource Sharing (Cors) on
requests matching the specified path (except the static resources,
for whom cors has to be activated directly!)
- Specified by:
cors
in interface Router<R extends RequestContext<?>,W extends WebsocketContext<?>>
- See Also:
SpincastFilters#cors(R context,
Set<String> allowedOrigins,
Set<String> extraHeadersAllowedToBeRead)
-
cors
public void cors(String path,
Set<String> allowedOrigins,
Set<String> extraHeadersAllowedToBeRead,
Set<String> extraHeadersAllowedToBeSent)
Description copied from interface: Router
Enables Cross-Origin Resource Sharing (Cors) on
requests matching the specified path (except the static resources,
for whom cors has to be activated directly!)
- Specified by:
cors
in interface Router<R extends RequestContext<?>,W extends WebsocketContext<?>>
- See Also:
SpincastFilters#cors(R context,
Set<String> allowedOrigins,
Set<String> extraHeadersAllowedToBeRead,
Set<String> extraHeadersAllowedToBeSent)
-
cors
public void cors(String path,
Set<String> allowedOrigins,
Set<String> extraHeadersAllowedToBeRead,
Set<String> extraHeadersAllowedToBeSent,
boolean allowCookies)
Description copied from interface: Router
Enables Cross-Origin Resource Sharing (Cors) on
requests matching the specified path (except the static resources,
for whom cors has to be activated directly!)
- Specified by:
cors
in interface Router<R extends RequestContext<?>,W extends WebsocketContext<?>>
- See Also:
SpincastFilters#cors(R context,
Set<String> allowedOrigins,
Set<String> extraHeadersAllowedToBeRead,
Set<String> extraHeadersAllowedToBeSent,
boolean allowCookies)
-
cors
public void cors(String path,
Set<String> allowedOrigins,
Set<String> extraHeadersAllowedToBeRead,
Set<String> extraHeadersAllowedToBeSent,
boolean allowCookies,
Set<HttpMethod> allowedMethods)
Description copied from interface: Router
Enables Cross-Origin Resource Sharing (Cors) on
requests matching the specified path (except the static resources,
for whom cors has to be activated directly!)
- Specified by:
cors
in interface Router<R extends RequestContext<?>,W extends WebsocketContext<?>>
- See Also:
SpincastFilters#cors(R context,
Set<String> allowedOrigins,
Set<String> extraHeadersAllowedToBeRead,
Set<String> extraHeadersAllowedToBeSent,
boolean allowCookies,
Set<HttpMethod> allowedMethods)
-
cors
public void cors(String path,
Set<String> allowedOrigins,
Set<String> extraHeadersAllowedToBeRead,
Set<String> extraHeadersAllowedToBeSent,
boolean allowCookies,
Set<HttpMethod> allowedMethods,
int maxAgeInSeconds)
Description copied from interface: Router
Enables Cross-Origin Resource Sharing (Cors) on
requests matching the specified path (except the static resources,
for whom cors has to be activated directly!)
- Specified by:
cors
in interface Router<R extends RequestContext<?>,W extends WebsocketContext<?>>
- See Also:
SpincastFilters#cors(R context,
Set<String> allowedOrigins,
Set<String> extraHeadersAllowedToBeRead,
Set<String> extraHeadersAllowedToBeSent,
boolean allowCookies,
Set<HttpMethod> allowedMethods,
int maxAgeInSeconds)
-
file
public StaticResourceBuilder<R> file(String url)
Description copied from interface: Router
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.
- Specified by:
file
in interface Router<R extends RequestContext<?>,W extends WebsocketContext<?>>
- Parameters:
url
- The url which will trigger the output of this
static resource.
-
dir
public StaticResourceBuilder<R> dir(String url)
Description copied from interface: Router
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.
- Specified by:
dir
in interface Router<R extends RequestContext<?>,W extends WebsocketContext<?>>
- Parameters:
url
- The url which will trigger the output of this
static resource.
-
addStaticResource
public void addStaticResource(StaticResource<R> staticResource)
Description copied from interface: Router
Adds a static resource
route, directly.
- Specified by:
addStaticResource
in interface Router<R extends RequestContext<?>,W extends WebsocketContext<?>>
-
isCreateStaticResourceOnDisk
protected boolean isCreateStaticResourceOnDisk()
-
httpAuth
public void httpAuth(String pathPrefix,
String realmName)
Description copied from interface: Router
Creates HTTP authentication protection (realm) for the
specified path prefix.
- Specified by:
httpAuth
in interface Router<R extends RequestContext<?>,W extends WebsocketContext<?>>
-
websocket
public WebsocketRouteBuilder<R,W> websocket(String path)
Description copied from interface: Router
Starts the creation of a Websocket route
.
- Specified by:
websocket
in interface Router<R extends RequestContext<?>,W extends WebsocketContext<?>>
-
addWebsocketRoute
public void addWebsocketRoute(WebsocketRoute<R,W> websocketRoute)
Description copied from interface: Router
Adds a Websocket route, directly.
- Specified by:
addWebsocketRoute
in interface Router<R extends RequestContext<?>,W extends WebsocketContext<?>>
-
createHttpRouteFromWebsocketRoute
protected Route<R> createHttpRouteFromWebsocketRoute(WebsocketRoute<R,W> websocketRoute)
-
redirect
public RedirectRuleBuilder<R,W> redirect(String oldPath)
Description copied from interface: Router
Starts the creation of a redirection rule.
- Specified by:
redirect
in interface Router<R extends RequestContext<?>,W extends WebsocketContext<?>>
- Parameters:
oldPath
- The old path that needs to be redirected.
Copyright © 2019. All rights reserved.