Interface RouteBuilder<R extends RequestContext<?>>
- All Known Implementing Classes:
RouteBuilderDefault
-
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()
AddsDELETE
as a supported HTTP method.This route will be considered during anException
routing process.found()
This route will be considered during aFound
routing process.GET()
AddssGET
as a supported HTTP method.void
Creates the route and saves it to the router.HEAD()
AddsHEAD
as a supported HTTP method.html()
Addsapplication/html
as an acceptedContent-Type
.An id that can be used to identify the route.json()
Addsapplication/json
as 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 Found
routing process.OPTIONS()
AddsOPTIONS
as a supported HTTP method.PATCH()
AddsPATCH
as a supported HTTP method.The path of the route.pos
(int position) The position of the handler.POST()
AddsPOST
as a supported HTTP method.PUT()
AddsPUT
as 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()
AddsTRACE
as a supported HTTP method.xml()
Addsapplication/xml
as an acceptedContent-Type
.
-
Method Details
-
spicastCoreRouteOrPluginRoute
RouteBuilder<R> spicastCoreRouteOrPluginRoute()This 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)
withtrue
will 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. -
id
An id that can be used to identify the route. Must be unique. -
classes
A 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.
-
path
The path of the route. -
pos
The 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
RedirectException
is thrown, but the response will then be closed!If not specified, "0" is used.
-
found
RouteBuilder<R> found()This route will be considered during aFound
routing process. -
notFound
RouteBuilder<R> notFound()This route will be considered during aNot Found
routing process. -
exception
RouteBuilder<R> exception()This route will be considered during anException
routing process. -
allRoutingTypes
RouteBuilder<R> allRoutingTypes()This route will be considered for all routing types. -
before
Adds 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. -
after
Adds 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. -
acceptAsString
Sets the acceptedContent-Types
. This route will only be considered for requests specifying thoseContent-Types
as being accepted (using theAccept
header). -
acceptAsString
Sets the acceptedContent-Types
. This route will only be considered for requests specifying thoseContent-Types
as being accepted (using theAccept
header). -
accept
Sets the acceptedContent-Types
. This route will only be considered for requests specifying thoseContent-Types
as being accepted (using theAccept
header). -
accept
Sets the acceptedContent-Types
. This route will only be considered for requests specifying thoseContent-Types
as being accepted (using theAccept
header). -
html
RouteBuilder<R> html()Addsapplication/html
as an acceptedContent-Type
. -
json
RouteBuilder<R> json()Addsapplication/json
as an acceptedContent-Type
. -
xml
RouteBuilder<R> xml()Addsapplication/xml
as an acceptedContent-Type
. -
GET
RouteBuilder<R> GET()AddssGET
as a supported HTTP method. If you started the creation of the route from anRouter
object, you already specified some supported HTTP methods. This one will simply be added. -
POST
RouteBuilder<R> POST()AddsPOST
as a supported HTTP method. If you started the creation of the route from anRouter
object, you already specified some supported HTTP methods. This one will simply be added. -
PUT
RouteBuilder<R> PUT()AddsPUT
as a supported HTTP method. If you started the creation of the route from anRouter
object, you already specified some supported HTTP methods. This one will simply be added. -
DELETE
RouteBuilder<R> DELETE()AddsDELETE
as a supported HTTP method. If you started the creation of the route from anRouter
object, you already specified some supported HTTP methods. This one will simply be added. -
OPTIONS
RouteBuilder<R> OPTIONS()AddsOPTIONS
as a supported HTTP method. If you started the creation of the route from anRouter
object, you already specified some supported HTTP methods. This one will simply be added. -
TRACE
RouteBuilder<R> TRACE()AddsTRACE
as a supported HTTP method. If you started the creation of the route from anRouter
object, you already specified some supported HTTP methods. This one will simply be added. -
HEAD
RouteBuilder<R> HEAD()AddsHEAD
as a supported HTTP method. If you started the creation of the route from anRouter
object, you already specified some supported HTTP methods. This one will simply be added. -
PATCH
RouteBuilder<R> PATCH()AddsPATCH
as a supported HTTP method. If you started the creation of the route from anRouter
object, you already specified some supported HTTP methods. This one will simply be added. -
ALL
RouteBuilder<R> ALL()Adds all HTTP methods as being supported. If you started the creation of the route from anRouter
object, you already specified some supported HTTP methods. By calling this method, all methods will now be suported. -
methods
Adds the specified HTTP methods as being supported. If you started the creation of the route from anRouter
object, you already specified some supported HTTP methods. Those new ones will simply be added. -
methods
Adds the specified HTTP methods as being supported. If you started the creation of the route from anRouter
object, you already specified some supported HTTP methods. Those new ones will simply be added. -
handle
Creates the route and saves it to the router. If the creation of the route was not started using anRouter
object, an exception will be thrown. -
create
Creates 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! -
noCache
RouteBuilder<R> noCache()Automatically adds "no-cache" headers to the response. -
cache
RouteBuilder<R> cache()Adds cache headers.Uses the default cache configurations, provided by
SpincastConfig
-
cache
Adds public cache headers.- Parameters:
seconds
- The number of seconds the resource associated with this route should be cached.
-
cache
Adds cache headers.- Parameters:
seconds
- The number of seconds the resource associated with this route should be cached.isPrivate
- should the cache be private? (help)
-
cache
Adds cache headers.- 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.
-
skip
Skip 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.
-
skipResourcesRequests
RouteBuilder<R> skipResourcesRequests()Won'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 thisskipResourcesRequests()
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.
-
specs
Generic method to provide specifications for an endpoint.Does nothing by default. Requires a plugin that knows how to parse the provided object.
-
specsIgnore
RouteBuilder<R> specsIgnore()When calling this method, the associated route won't be part of the generated specs.
-