Class RouteBuilderDefault<R extends RequestContext<?>,W extends WebsocketContext<?>>
- All Implemented Interfaces:
RouteBuilder<R>
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionRouteBuilderDefault(Router<R, W> router, RouteFactory<R> routeFactory, SpincastRouterConfig spincastRouterConfig, SpincastFilters<R> spincastFilters, SpincastConfig spincastConfig) RouteBuilderDefault(RouteFactory<R> routeFactory, SpincastRouterConfig spincastRouterConfig, SpincastFilters<R> spincastFilters, SpincastConfig spincastConfig) -
Method Summary
Modifier and TypeMethodDescriptionaccept(Set<ContentTypeDefaults> acceptedContentTypes) Sets the acceptedContent-Types.accept(ContentTypeDefaults... acceptedContentTypes) Sets the acceptedContent-Types.acceptAsString(String... acceptedContentTypes) Sets the acceptedContent-Types.acceptAsString(Set<String> acceptedContentTypes) Sets the acceptedContent-Types.Adds an "after" filter which will only be applied to this particular route.ALL()Adds all HTTP methods as being supported.This route will be considered for all routing types.Adds a "before" filter which will only be applied to this particular route.cache()Adds cache headers.cache(int seconds) Adds public cache headers.cache(int seconds, boolean isPrivate) Adds cache headers.Adds cache headers.A route may have multiple "classes" to identify and group them.Creates and returns the route without adding it to the router.DELETE()AddsDELETEas a supported HTTP method.This route will be considered during anExceptionrouting process.found()This route will be considered during aFoundrouting process.GET()AddssGETas a supported HTTP method.protected Integerprotected intgetId()getPath()intprotected RouteFactory<R>getSpecs()May benull.Object[]protected SpincastConfigprotected SpincastFilters<R>protected SpincastRouterConfigvoidCreates the route and saves it to the router.HEAD()AddsHEADas a supported HTTP method.html()Addsapplication/htmlas an acceptedContent-Type.An id that can be used to identify the route.protected booleanbooleanbooleanbooleanjson()Addsapplication/jsonas an acceptedContent-Type.methods(Set<HttpMethod> httpMethods) Adds the specified HTTP methods as being supported.methods(HttpMethod... httpMethods) Adds the specified HTTP methods as being supported.noCache()Automatically adds "no-cache" headers to the response.notFound()This route will be considered during aNot Foundrouting process.OPTIONS()AddsOPTIONSas a supported HTTP method.PATCH()AddsPATCHas a supported HTTP method.The path of the route.pos(int position) The position of the handler.POST()AddsPOSTas a supported HTTP method.PUT()AddsPUTas a supported HTTP method.Skip a "before" and "after" filter for this route.Won't be applied if the request is for a resource (Route.isStaticResourceRoute()).Generic method to provide specifications for an endpoint.When calling this method, the associated route won't be part of the generated specs.This should only by called by *plugins*.TRACE()AddsTRACEas a supported HTTP method.xml()Addsapplication/xmlas an acceptedContent-Type.
-
Field Details
-
logger
protected static final org.slf4j.Logger logger
-
-
Constructor Details
-
RouteBuilderDefault
public RouteBuilderDefault(RouteFactory<R> routeFactory, SpincastRouterConfig spincastRouterConfig, SpincastFilters<R> spincastFilters, SpincastConfig spincastConfig) -
RouteBuilderDefault
public RouteBuilderDefault(Router<R, W> router, RouteFactory<R> routeFactory, SpincastRouterConfig spincastRouterConfig, SpincastFilters<R> spincastFilters, SpincastConfig spincastConfig)
-
-
Method Details
-
getRouter
-
getRouteFactory
-
getSpincastRouterConfig
-
getSpincastFilters
-
getSpincastConfig
-
getId
-
getClasses
-
isSpicastCoreRouteOrPluginRoute
public boolean isSpicastCoreRouteOrPluginRoute() -
getPath
-
getPosition
public int getPosition() -
isSkipResources
public boolean isSkipResources() -
getRoutingTypes
-
getHttpMethods
-
getBeforeFilters
-
getAfterFilters
-
getMainHandler
-
getAcceptedContentTypes
-
getFilterIdsToSkip
-
getSpecs
May benull. -
isSpecsIgnore
public boolean isSpecsIgnore() -
getSpecsParameters
-
id
Description copied from interface:RouteBuilderAn id that can be used to identify the route. Must be unique.- Specified by:
idin interfaceRouteBuilder<R extends RequestContext<?>>
-
classes
Description copied from interface:RouteBuilderA route may have multiple "classes" to identify and group them.For example, multiple routes may share the same "account" class and this information could be used to set a menu item as being active on an HTML page.
- Specified by:
classesin interfaceRouteBuilder<R extends RequestContext<?>>
-
spicastCoreRouteOrPluginRoute
Description copied from interface:RouteBuilderThis should only by called by *plugins*.When this method is called, the resulting route won't be remove by default when the
Router.removeAllRoutes()method is used. TheRouter.removeAllRoutes(boolean)withtruewill have to be called to actually remove it.This is useful during development, when an hotreload mecanism is used to reload the Router without restarting the application, when the application routes changed. By default only the routes for which the
#isSpicastCoreRouteOrPluginRoute()method has been called would then be reloaded.- Specified by:
spicastCoreRouteOrPluginRoutein interfaceRouteBuilder<R extends RequestContext<?>>
-
pos
Description copied from interface:RouteBuilderThe position of the handler.If "0", the handler is considered as the *main* handler. Only one main handler per request is run (the first one found)! The main handler is usually where the body of the response is created.
A route with a position less than "0" is considered as a "before" filter and will be run before the main handler. A route with a position greater than "0" is considered as an "after" filter and will be run after the main handler. All the matching before and after filters are run, from the lower position to the higher. If two filters have the same position, they will be run in order they have been added to the router.
Be especially careful with after filters since the response may have been flushed at that time. For example, after filters are run if a
RedirectExceptionis thrown, but the response will then be closed!If not specified, "0" is used.
- Specified by:
posin interfaceRouteBuilder<R extends RequestContext<?>>
-
allRoutingTypes
Description copied from interface:RouteBuilderThis route will be considered for all routing types.- Specified by:
allRoutingTypesin interfaceRouteBuilder<R extends RequestContext<?>>
-
found
Description copied from interface:RouteBuilderThis route will be considered during aFoundrouting process.- Specified by:
foundin interfaceRouteBuilder<R extends RequestContext<?>>
-
notFound
Description copied from interface:RouteBuilderThis route will be considered during aNot Foundrouting process.- Specified by:
notFoundin interfaceRouteBuilder<R extends RequestContext<?>>
-
exception
Description copied from interface:RouteBuilderThis route will be considered during anExceptionrouting process.- Specified by:
exceptionin interfaceRouteBuilder<R extends RequestContext<?>>
-
before
Description copied from interface:RouteBuilderAdds a "before" filter which will only be applied to this particular route. If more than one filter is added, they will be run in order they have been added.- Specified by:
beforein interfaceRouteBuilder<R extends RequestContext<?>>
-
after
Description copied from interface:RouteBuilderAdds an "after" filter which will only be applied to this particular route. If more than one filter is added, they will be run in order they have been added.- Specified by:
afterin interfaceRouteBuilder<R extends RequestContext<?>>
-
acceptAsString
Description copied from interface:RouteBuilderSets the acceptedContent-Types. This route will only be considered for requests specifying thoseContent-Typesas being accepted (using theAcceptheader).- Specified by:
acceptAsStringin interfaceRouteBuilder<R extends RequestContext<?>>
-
acceptAsString
Description copied from interface:RouteBuilderSets the acceptedContent-Types. This route will only be considered for requests specifying thoseContent-Typesas being accepted (using theAcceptheader).- Specified by:
acceptAsStringin interfaceRouteBuilder<R extends RequestContext<?>>
-
accept
Description copied from interface:RouteBuilderSets the acceptedContent-Types. This route will only be considered for requests specifying thoseContent-Typesas being accepted (using theAcceptheader).- Specified by:
acceptin interfaceRouteBuilder<R extends RequestContext<?>>
-
accept
Description copied from interface:RouteBuilderSets the acceptedContent-Types. This route will only be considered for requests specifying thoseContent-Typesas being accepted (using theAcceptheader).- Specified by:
acceptin interfaceRouteBuilder<R extends RequestContext<?>>
-
html
Description copied from interface:RouteBuilderAddsapplication/htmlas an acceptedContent-Type.- Specified by:
htmlin interfaceRouteBuilder<R extends RequestContext<?>>
-
json
Description copied from interface:RouteBuilderAddsapplication/jsonas an acceptedContent-Type.- Specified by:
jsonin interfaceRouteBuilder<R extends RequestContext<?>>
-
xml
Description copied from interface:RouteBuilderAddsapplication/xmlas an acceptedContent-Type.- Specified by:
xmlin interfaceRouteBuilder<R extends RequestContext<?>>
-
path
Description copied from interface:RouteBuilderThe path of the route.- Specified by:
pathin interfaceRouteBuilder<R extends RequestContext<?>>
-
GET
Description copied from interface:RouteBuilderAddssGETas a supported HTTP method. If you started the creation of the route from anRouterobject, you already specified some supported HTTP methods. This one will simply be added.- Specified by:
GETin interfaceRouteBuilder<R extends RequestContext<?>>
-
POST
Description copied from interface:RouteBuilderAddsPOSTas a supported HTTP method. If you started the creation of the route from anRouterobject, you already specified some supported HTTP methods. This one will simply be added.- Specified by:
POSTin interfaceRouteBuilder<R extends RequestContext<?>>
-
PUT
Description copied from interface:RouteBuilderAddsPUTas a supported HTTP method. If you started the creation of the route from anRouterobject, you already specified some supported HTTP methods. This one will simply be added.- Specified by:
PUTin interfaceRouteBuilder<R extends RequestContext<?>>
-
DELETE
Description copied from interface:RouteBuilderAddsDELETEas a supported HTTP method. If you started the creation of the route from anRouterobject, you already specified some supported HTTP methods. This one will simply be added.- Specified by:
DELETEin interfaceRouteBuilder<R extends RequestContext<?>>
-
OPTIONS
Description copied from interface:RouteBuilderAddsOPTIONSas a supported HTTP method. If you started the creation of the route from anRouterobject, you already specified some supported HTTP methods. This one will simply be added.- Specified by:
OPTIONSin interfaceRouteBuilder<R extends RequestContext<?>>
-
TRACE
Description copied from interface:RouteBuilderAddsTRACEas a supported HTTP method. If you started the creation of the route from anRouterobject, you already specified some supported HTTP methods. This one will simply be added.- Specified by:
TRACEin interfaceRouteBuilder<R extends RequestContext<?>>
-
HEAD
Description copied from interface:RouteBuilderAddsHEADas a supported HTTP method. If you started the creation of the route from anRouterobject, you already specified some supported HTTP methods. This one will simply be added.- Specified by:
HEADin interfaceRouteBuilder<R extends RequestContext<?>>
-
PATCH
Description copied from interface:RouteBuilderAddsPATCHas a supported HTTP method. If you started the creation of the route from anRouterobject, you already specified some supported HTTP methods. This one will simply be added.- Specified by:
PATCHin interfaceRouteBuilder<R extends RequestContext<?>>
-
ALL
Description copied from interface:RouteBuilderAdds all HTTP methods as being supported. If you started the creation of the route from anRouterobject, you already specified some supported HTTP methods. By calling this method, all methods will now be suported.- Specified by:
ALLin interfaceRouteBuilder<R extends RequestContext<?>>
-
methods
Description copied from interface:RouteBuilderAdds the specified HTTP methods as being supported. If you started the creation of the route from anRouterobject, you already specified some supported HTTP methods. Those new ones will simply be added.- Specified by:
methodsin interfaceRouteBuilder<R extends RequestContext<?>>
-
methods
Description copied from interface:RouteBuilderAdds the specified HTTP methods as being supported. If you started the creation of the route from anRouterobject, you already specified some supported HTTP methods. Those new ones will simply be added.- Specified by:
methodsin interfaceRouteBuilder<R extends RequestContext<?>>
-
handle
Description copied from interface:RouteBuilderCreates the route and saves it to the router. If the creation of the route was not started using anRouterobject, an exception will be thrown.- Specified by:
handlein interfaceRouteBuilder<R extends RequestContext<?>>
-
create
Description copied from interface:RouteBuilderCreates and returns the route without adding it to the router. NOTE : usehandle(...)instead to save the route to the router at the end of the build process!- Specified by:
createin interfaceRouteBuilder<R extends RequestContext<?>>
-
noCache
Description copied from interface:RouteBuilderAutomatically adds "no-cache" headers to the response.- Specified by:
noCachein interfaceRouteBuilder<R extends RequestContext<?>>
-
cache
Description copied from interface:RouteBuilderAdds cache headers.Uses the default cache configurations, provided by
SpincastConfig- Specified by:
cachein interfaceRouteBuilder<R extends RequestContext<?>>
-
cache
Description copied from interface:RouteBuilderAdds public cache headers.- Specified by:
cachein interfaceRouteBuilder<R extends RequestContext<?>>- Parameters:
seconds- The number of seconds the resource associated with this route should be cached.
-
cache
Description copied from interface:RouteBuilderAdds cache headers.- Specified by:
cachein interfaceRouteBuilder<R extends RequestContext<?>>- Parameters:
seconds- The number of seconds the resource associated with this route should be cached.isPrivate- should the cache be private? (help)
-
cache
Description copied from interface:RouteBuilderAdds cache headers.- Specified by:
cachein interfaceRouteBuilder<R extends RequestContext<?>>- Parameters:
seconds- The number of seconds the resource associated with this route should be cached.isPrivate- should the cache be private? (help)secondsCdn- The number of seconds the resource associated with this route should be cached by a CDN/proxy. Ifnull, it won't be used.
-
getCacheSecondsByDefault
protected int getCacheSecondsByDefault() -
isCachePrivateByDefault
protected boolean isCachePrivateByDefault() -
getCacheCdnSecondsByDefault
-
skip
Description copied from interface:RouteBuilderSkip a "before" and "after" filter for this route.This is useful when you set a global filter but want to skip it one a specific route only.
- Specified by:
skipin interfaceRouteBuilder<R extends RequestContext<?>>
-
skipResourcesRequests
Description copied from interface:RouteBuilderWon't be applied if the request is for a resource (Route.isStaticResourceRoute()). In the case of Dynamic Resources, the filters will indeed be called when the generator is used. By calling thisRouteBuilder.skipResourcesRequests()method, the current filter will never be called for such resources.This feature only makes sense if the current route if a filter. Otherwise, it won't be used.
- Specified by:
skipResourcesRequestsin interfaceRouteBuilder<R extends RequestContext<?>>
-
specs
Description copied from interface:RouteBuilderGeneric method to provide specifications for an endpoint.Does nothing by default. Requires a plugin that knows how to parse the provided object.
- Specified by:
specsin interfaceRouteBuilder<R extends RequestContext<?>>
-
specsIgnore
Description copied from interface:RouteBuilderWhen calling this method, the associated route won't be part of the generated specs.- Specified by:
specsIgnorein interfaceRouteBuilder<R extends RequestContext<?>>
-