public class SpincastRouter<R extends RequestContext<?>,W extends WebsocketContext<?>> extends Object implements Router<R,W>
| Modifier and Type | Field and Description |
|---|---|
protected org.slf4j.Logger |
logger |
DEFAULT_ROUTE_PATH| Constructor and Description |
|---|
SpincastRouter(SpincastRouterDeps<R,W> spincastRouterDeps) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
addDefaultFilters() |
protected RouteBuilder<R> |
addFilterDefaultRoutingTypes(RouteBuilder<R> builder) |
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> |
after()
Creates an "after" filter.
|
protected RouteBuilder<R> |
after(RouteBuilder<R> builder,
String path) |
RouteBuilder<R> |
after(String path)
Creates an "after" filter.
|
RouteBuilder<R> |
ALL(String path)
Starts the creation of a route matching any HTTP method.
|
RouteBuilder<R> |
before()
Creates a "before" filter.
|
RouteBuilder<R> |
before(String path)
Creates a "before" filter.
|
RouteBuilder<R> |
beforeAndAfter()
Creates a "before" and an "after" filters.
|
RouteBuilder<R> |
beforeAndAfter(String path)
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!)
|
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(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(String path)
Starts the creation of a
GET route. |
protected int |
getAfterFilterDefaultPosition() |
protected int |
getBeforeFilterDefaultPosition() |
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() |
protected Set<String> |
getRouteIdsPrefixToKeepByDefaultWhenRemovingAll()
The route with ids starting with those prefixes won't be removed
by default when removeAllRoutes() is called without the
"delete all" parameter.
|
Map<String,String> |
getRouteParamPatternAliases()
The path patterns' aliases.
|
protected Server |
getServer() |
protected SpincastConfig |
getSpincastConfig() |
protected SpincastDictionary |
getSpincastDictionary() |
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(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 |
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) |
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(String path)
Starts the creation of a
OPTIONS route. |
RouteBuilder<R> |
PATCH(String path)
Starts the creation of a
PATCH route. |
RouteBuilder<R> |
POST(String path)
Starts the creation of a
POST route. |
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 routes, except the one Spincast
addds automatically (their ids start with "spincast_").
|
void |
removeAllRoutes(boolean removeSpincastRoutesToo)
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) |
RouteBuilder<R> |
SOME(String path,
HttpMethod... httpMethods)
Starts the creation of a route matching the specified
HTTP methods.
|
RouteBuilder<R> |
SOME(String path,
Set<HttpMethod> httpMethods)
Starts the creation of a route matching the specified
HTTP methods.
|
protected boolean |
startsWithAnyOf(String id,
Set<String> prefixes) |
RouteBuilder<R> |
TRACE(String path)
Starts the creation of a
TRACE route. |
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. |
@Inject public SpincastRouter(SpincastRouterDeps<R,W> spincastRouterDeps)
@Inject protected void init()
protected void validation()
protected void addDefaultFilters()
protected SpincastRouterConfig getSpincastRouterConfig()
protected RouteFactory<R> getRouteFactory()
protected SpincastConfig getSpincastConfig()
protected SpincastDictionary getSpincastDictionary()
protected Server getServer()
protected SpincastFilters<R> getSpincastFilters()
protected RouteBuilderFactory<R,W> getRouteBuilderFactory()
protected RedirectRuleBuilderFactory<R,W> getRedirectRuleBuilderFactory()
protected WebsocketRouteBuilderFactory<R,W> getWebsocketRouteBuilderFactory()
protected WebsocketRouteHandlerFactory<R,W> getWebsocketRouteHandlerFactory()
protected StaticResourceBuilderFactory<R,W> getStaticResourceBuilderFactory()
protected RouteHandlerMatchFactory<R> getRouteHandlerMatchFactory()
protected StaticResourceFactory<R> getStaticResourceFactory()
protected SpincastRoutingUtils getSpincastRoutingUtils()
public Map<String,String> getRouteParamPatternAliases()
RoutergetRouteParamPatternAliases in interface Router<R extends RequestContext<?>,W extends WebsocketContext<?>>public Route<R> getRoute(String routeId)
RouterrouteId.getRoute in interface Router<R extends RequestContext<?>,W extends WebsocketContext<?>>protected Map<Integer,List<Route<R>>> getGlobalBeforeFiltersPerPosition()
public List<Route<R>> getGlobalBeforeFiltersRoutes()
RoutergetGlobalBeforeFiltersRoutes in interface Router<R extends RequestContext<?>,W extends WebsocketContext<?>>protected Map<Integer,List<Route<R>>> getGlobalAfterFiltersPerPosition()
public List<Route<R>> getGlobalAfterFiltersRoutes()
RoutergetGlobalAfterFiltersRoutes in interface Router<R extends RequestContext<?>,W extends WebsocketContext<?>>public List<Route<R>> getMainRoutes()
RoutergetMainRoutes in interface Router<R extends RequestContext<?>,W extends WebsocketContext<?>>public void addRoute(Route<R> route)
RouteraddRoute in interface Router<R extends RequestContext<?>,W extends WebsocketContext<?>>protected void validateId(String id)
protected void validatePath(String path)
public void removeAllRoutes()
RouterremoveAllRoutes in interface Router<R extends RequestContext<?>,W extends WebsocketContext<?>>public void removeAllRoutes(boolean removeSpincastRoutesToo)
RouterremoveAllRoutes in interface Router<R extends RequestContext<?>,W extends WebsocketContext<?>>removeSpincastRoutesToo - Should the routes added by
Spincast be removed too?protected Set<String> getRouteIdsPrefixToKeepByDefaultWhenRemovingAll()
public void removeRoute(String routeId)
RouterrouteId.removeRoute in interface Router<R extends RequestContext<?>,W extends WebsocketContext<?>>public RoutingResult<R> route(R requestContext)
Routerroute in interface Router<R extends RequestContext<?>,W extends WebsocketContext<?>>null if no route matches.public RoutingResult<R> route(R requestContext, RoutingType routingType)
Routerroute in interface Router<R extends RequestContext<?>,W extends WebsocketContext<?>>null if no route matches.public RoutingResult<R> route(R requestContext, String fullUrl, RoutingType routingType)
protected boolean isRoutingTypeMatch(RoutingType routingType, Route<R> route)
protected RoutingResult<R> createRoutingResult(List<RouteHandlerMatch<R>> routeHandlerMatches)
protected List<RouteHandlerMatch<R>> createRegularHandlerMatches(RoutingType routingType, Route<R> route, HttpMethod httpMethod, List<String> acceptedContentTypes, URL url, int position)
protected boolean isRouteMatchAcceptedContentType(Route<R> route, List<String> requestContentTypes)
protected RouteHandlerMatch<R> createNoMatchingParamsHandlerMatch(Route<R> route, String id, Handler<R> handler, int position)
protected RouteHandlerMatch<R> createHandlerMatchForBeforeOrAfterFilter(RouteHandlerMatch<R> mainRouteHandlerMatch, Handler<R> beforeOrAfterMethod, int position)
protected boolean isRouteMatchHttpMethod(Route<R> route, HttpMethod httpMethod)
protected Map<String,String> validatePath(String routePath, URL url)
protected String getPatternFromAlias(String alias)
public void addRouteParamPatternAlias(String alias, String pattern)
Router"/${param1:<XXX>}" : here "XXX" is the alias for the
regular expression pattern to use.addRouteParamPatternAlias in interface Router<R extends RequestContext<?>,W extends WebsocketContext<?>>public RouteBuilder<R> GET(String path)
RouterGET route.GET in interface Router<R extends RequestContext<?>,W extends WebsocketContext<?>>public RouteBuilder<R> POST(String path)
RouterPOST route.POST in interface Router<R extends RequestContext<?>,W extends WebsocketContext<?>>public RouteBuilder<R> PUT(String path)
RouterPUT route.PUT in interface Router<R extends RequestContext<?>,W extends WebsocketContext<?>>public RouteBuilder<R> DELETE(String path)
RouterDELETE route.DELETE in interface Router<R extends RequestContext<?>,W extends WebsocketContext<?>>public RouteBuilder<R> OPTIONS(String path)
RouterOPTIONS route.OPTIONS in interface Router<R extends RequestContext<?>,W extends WebsocketContext<?>>public RouteBuilder<R> TRACE(String path)
RouterTRACE route.TRACE in interface Router<R extends RequestContext<?>,W extends WebsocketContext<?>>public RouteBuilder<R> HEAD(String path)
RouterHEAD route.HEAD in interface Router<R extends RequestContext<?>,W extends WebsocketContext<?>>public RouteBuilder<R> PATCH(String path)
RouterPATCH route.PATCH in interface Router<R extends RequestContext<?>,W extends WebsocketContext<?>>public RouteBuilder<R> ALL(String path)
RouterALL in interface Router<R extends RequestContext<?>,W extends WebsocketContext<?>>public RouteBuilder<R> SOME(String path, HttpMethod... httpMethods)
RouterSOME in interface Router<R extends RequestContext<?>,W extends WebsocketContext<?>>public RouteBuilder<R> SOME(String path, Set<HttpMethod> httpMethods)
RouterSOME in interface Router<R extends RequestContext<?>,W extends WebsocketContext<?>>public RouteBuilder<R> before()
RouterALL("/*{path}").pos(-10)
and with the Routing types as returned by
SpincastRouterConfig#getFilterDefaultRoutingTypes()before in interface Router<R extends RequestContext<?>,W extends WebsocketContext<?>>public RouteBuilder<R> before(String path)
RouterALL(path).pos(-10)
and with the Routing types as returned by
SpincastRouterConfig#getFilterDefaultRoutingTypes()before in interface Router<R extends RequestContext<?>,W extends WebsocketContext<?>>protected int getBeforeFilterDefaultPosition()
protected int getAfterFilterDefaultPosition()
public RouteBuilder<R> after()
RouterALL("/*{path}").pos(10)
and with the Routing types as returned by
SpincastRouterConfig#getFilterDefaultRoutingTypes()after in interface Router<R extends RequestContext<?>,W extends WebsocketContext<?>>public RouteBuilder<R> after(String path)
RouterALL(path).pos(10))
and with the Routing types as returned by
SpincastRouterConfig#getFilterDefaultRoutingTypes()after in interface Router<R extends RequestContext<?>,W extends WebsocketContext<?>>protected RouteBuilder<R> after(RouteBuilder<R> builder, String path)
public RouteBuilder<R> beforeAndAfter()
RouterALL("/*{path}").pos(-10)
and
ALL("/*{path}").pos(10)
and with the Routing types as returned by
SpincastRouterConfig#getFilterDefaultRoutingTypes()beforeAndAfter in interface Router<R extends RequestContext<?>,W extends WebsocketContext<?>>public RouteBuilder<R> beforeAndAfter(String path)
RouterALL(path).pos(-10)
and
ALL(path).pos(10)
and with the Routing types as returned by
SpincastRouterConfig#getFilterDefaultRoutingTypes()beforeAndAfter in interface Router<R extends RequestContext<?>,W extends WebsocketContext<?>>protected RouteBuilder<R> addFilterDefaultRoutingTypes(RouteBuilder<R> builder)
public void exception(Handler<R> handler)
RouterALL("/*{path}").exception().save(handler)exception in interface Router<R extends RequestContext<?>,W extends WebsocketContext<?>>public void exception(String path, Handler<R> handler)
RouterALL(path).exception().save(handler)exception in interface Router<R extends RequestContext<?>,W extends WebsocketContext<?>>public void notFound(Handler<R> handler)
RouterALL("/*{path}").notFound().save(handler)notFound in interface Router<R extends RequestContext<?>,W extends WebsocketContext<?>>public void notFound(String path, Handler<R> handler)
RouterALL(path).notFound().save(handler)notFound in interface Router<R extends RequestContext<?>,W extends WebsocketContext<?>>public void cors()
Routercors in interface Router<R extends RequestContext<?>,W extends WebsocketContext<?>>SpincastFilters#cors(R context)public void cors(Set<String> allowedOrigins)
Routercors in interface Router<R extends RequestContext<?>,W extends WebsocketContext<?>>SpincastFilters#cors(R context,
Set<String> allowedOrigins)public void cors(Set<String> allowedOrigins, Set<String> extraHeadersAllowedToBeRead)
Routercors in interface Router<R extends RequestContext<?>,W extends WebsocketContext<?>>SpincastFilters#cors(R context,
Set<String> allowedOrigins,
Set<String> extraHeadersAllowedToBeReadt)public void cors(Set<String> allowedOrigins, Set<String> extraHeadersAllowedToBeRead, Set<String> extraHeadersAllowedToBeSent)
Routercors in interface Router<R extends RequestContext<?>,W extends WebsocketContext<?>>SpincastFilters#cors(R context,
Set<String> allowedOrigins,
Set<String> extraHeadersAllowedToBeRead,
Set<String> extraHeadersAllowedToBeSent)public void cors(Set<String> allowedOrigins, Set<String> extraHeadersAllowedToBeRead, Set<String> extraHeadersAllowedToBeSent, boolean allowCookies)
Routercors in interface Router<R extends RequestContext<?>,W extends WebsocketContext<?>>SpincastFilters#cors(R context,
Set<String> allowedOrigins,
Set<String> extraHeadersAllowedToBeRead,
Set<String> extraHeadersAllowedToBeSent,
boolean allowCookies)public void cors(Set<String> allowedOrigins, Set<String> extraHeadersAllowedToBeRead, Set<String> extraHeadersAllowedToBeSent, boolean allowCookies, Set<HttpMethod> allowedMethods)
Routercors in interface Router<R extends RequestContext<?>,W extends WebsocketContext<?>>SpincastFilters#cors(R context,
Set<String> allowedOrigins,
Set<String> extraHeadersAllowedToBeRead,
Set<String> extraHeadersAllowedToBeSent,
boolean allowCookies,
Set<HttpMethod> allowedMethods)public void cors(Set<String> allowedOrigins, Set<String> extraHeadersAllowedToBeRead, Set<String> extraHeadersAllowedToBeSent, boolean allowCookies, Set<HttpMethod> allowedMethods, int maxAgeInSeconds)
Routercors in interface Router<R extends RequestContext<?>,W extends WebsocketContext<?>>SpincastFilters#cors(R context,
Set<String> allowedOrigins,
Set<String> extraHeadersAllowedToBeRead,
Set<String> extraHeadersAllowedToBeSent,
boolean allowCookies,
Set<HttpMethod> allowedMethods,
int maxAgeInSeconds)public void cors(String path)
Routercors in interface Router<R extends RequestContext<?>,W extends WebsocketContext<?>>SpincastFilters#cors(R context)public void cors(String path, Set<String> allowedOrigins)
Routercors in interface Router<R extends RequestContext<?>,W extends WebsocketContext<?>>SpincastFilters#cors(R context,
Set<String> allowedOrigins)public void cors(String path, Set<String> allowedOrigins, Set<String> extraHeadersAllowedToBeRead)
Routercors in interface Router<R extends RequestContext<?>,W extends WebsocketContext<?>>SpincastFilters#cors(R context,
Set<String> allowedOrigins,
Set<String> extraHeadersAllowedToBeRead)public void cors(String path, Set<String> allowedOrigins, Set<String> extraHeadersAllowedToBeRead, Set<String> extraHeadersAllowedToBeSent)
Routercors in interface Router<R extends RequestContext<?>,W extends WebsocketContext<?>>SpincastFilters#cors(R context,
Set<String> allowedOrigins,
Set<String> extraHeadersAllowedToBeRead,
Set<String> extraHeadersAllowedToBeSent)public void cors(String path, Set<String> allowedOrigins, Set<String> extraHeadersAllowedToBeRead, Set<String> extraHeadersAllowedToBeSent, boolean allowCookies)
Routercors in interface Router<R extends RequestContext<?>,W extends WebsocketContext<?>>SpincastFilters#cors(R context,
Set<String> allowedOrigins,
Set<String> extraHeadersAllowedToBeRead,
Set<String> extraHeadersAllowedToBeSent,
boolean allowCookies)public void cors(String path, Set<String> allowedOrigins, Set<String> extraHeadersAllowedToBeRead, Set<String> extraHeadersAllowedToBeSent, boolean allowCookies, Set<HttpMethod> allowedMethods)
Routercors in interface Router<R extends RequestContext<?>,W extends WebsocketContext<?>>SpincastFilters#cors(R context,
Set<String> allowedOrigins,
Set<String> extraHeadersAllowedToBeRead,
Set<String> extraHeadersAllowedToBeSent,
boolean allowCookies,
Set<HttpMethod> allowedMethods)public void cors(String path, Set<String> allowedOrigins, Set<String> extraHeadersAllowedToBeRead, Set<String> extraHeadersAllowedToBeSent, boolean allowCookies, Set<HttpMethod> allowedMethods, int maxAgeInSeconds)
Routercors in interface Router<R extends RequestContext<?>,W extends WebsocketContext<?>>SpincastFilters#cors(R context,
Set<String> allowedOrigins,
Set<String> extraHeadersAllowedToBeRead,
Set<String> extraHeadersAllowedToBeSent,
boolean allowCookies,
Set<HttpMethod> allowedMethods,
int maxAgeInSeconds)public StaticResourceBuilder<R> file(String url)
Routerstatic 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.
file in interface Router<R extends RequestContext<?>,W extends WebsocketContext<?>>url - The url which will trigger the output of this
static resource.public StaticResourceBuilder<R> dir(String url)
Routerstatic 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.
dir in interface Router<R extends RequestContext<?>,W extends WebsocketContext<?>>url - The url which will trigger the output of this
static resource.public void addStaticResource(StaticResource<R> staticResource)
Routerstatic resource route, directly.addStaticResource in interface Router<R extends RequestContext<?>,W extends WebsocketContext<?>>protected boolean isCreateStaticResourceOnDisk()
public void httpAuth(String pathPrefix, String realmName)
RouterhttpAuth in interface Router<R extends RequestContext<?>,W extends WebsocketContext<?>>public WebsocketRouteBuilder<R,W> websocket(String path)
RouterWebsocket route.websocket in interface Router<R extends RequestContext<?>,W extends WebsocketContext<?>>public void addWebsocketRoute(WebsocketRoute<R,W> websocketRoute)
RouteraddWebsocketRoute in interface Router<R extends RequestContext<?>,W extends WebsocketContext<?>>protected Route<R> createHttpRouteFromWebsocketRoute(WebsocketRoute<R,W> websocketRoute)
public RedirectRuleBuilder redirect(String oldPath)
Routerredirect in interface Router<R extends RequestContext<?>,W extends WebsocketContext<?>>oldPath - The old path that needs to be redirected.Copyright © 2017. All rights reserved.