Interface StaticResourceBuilder<R extends RequestContext<?>>
- All Known Implementing Classes:
StaticResourceBuilderDefault
-
Method Summary
Modifier and TypeMethodDescriptioncache
(int seconds) Adds public cache headers.cache
(int seconds, boolean isPrivate) Adds cache headers.Adds cache headers.The path to the resource, on the classpath.cors()
Enables Cross-Origin Resource Sharing (Cors)Enables Cross-Origin Resource Sharing (Cors)Enables Cross-Origin Resource Sharing (Cors)cors
(Set<String> allowedOrigins, Set<String> extraHeadersAllowedToBeRead, Set<String> extraHeadersAllowedToBeSent) Enables Cross-Origin Resource Sharing (Cors)cors
(Set<String> allowedOrigins, Set<String> extraHeadersAllowedToBeRead, Set<String> extraHeadersAllowedToBeSent, boolean allowCookies) Enables Cross-Origin Resource Sharing (Cors)cors
(Set<String> allowedOrigins, Set<String> extraHeadersAllowedToBeRead, Set<String> extraHeadersAllowedToBeSent, boolean allowCookies, int maxAgeInSeconds) Enables Cross-Origin Resource Sharing (Cors)create()
Creates and returns the static resource without adding it to the router.void
handle()
Saves the static resource route to the router.void
Saves the static resource route.void
Saves the static resource route.When a static resource is flagged as being *hotlinking protected*, the server will validate theorigin
andreferer
of the request.hotlinkingProtected
(HotlinkingManager hotlinkingManager) When a static resource is flagged as being *hotlinking protected*, the server will validate theorigin
andreferer
of the request.pathAbsolute
(String absolutePath) The absolute path to the resource, on the file system.pathRelative
(String relativePath) The path to the resource, on the file system, relative to the temp Spincast directory, as returned bySpincastConfig::getSpincastTempDir()
This should only by called by *plugins*.The URL pointing to the resource.
-
Method Details
-
spicastOrPluginAddedResource
StaticResourceBuilder<R> spicastOrPluginAddedResource()This should only by called by *plugins*.When this method is called, the resulting route for the resource 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. -
url
The URL pointing to the resource. -
classpath
The path to the resource, on the classpath. -
pathAbsolute
The absolute path to the resource, on the file system.- Parameters:
absolutePath
- the absolute path to the resource. If this is a file and not a directory, remember that it will be served as a static resource, so its extension is important for the correctContent-Type
to be sent!
-
pathRelative
The path to the resource, on the file system, relative to the temp Spincast directory, as returned bySpincastConfig::getSpincastTempDir()
- Parameters:
relativePath
- the relative path to the resource. If this is a file and not a directory, remember that it will be served as a static resource, so its extension is important for the correctContent-Type
to be sent!
-
cors
StaticResourceBuilder<R> cors()Enables Cross-Origin Resource Sharing (Cors)- See Also:
-
SpincastFilters#cors(R context)
-
cors
Enables Cross-Origin Resource Sharing (Cors)- See Also:
-
SpincastFilters#cors(R context, Set<String> allowedOrigins)
-
cors
Enables Cross-Origin Resource Sharing (Cors)- See Also:
-
SpincastFilters#cors(R context, Set<String> allowedOrigins, Set<String> extraHeadersAllowedToBeRead)
-
cors
StaticResourceBuilder<R> cors(Set<String> allowedOrigins, Set<String> extraHeadersAllowedToBeRead, Set<String> extraHeadersAllowedToBeSent) Enables Cross-Origin Resource Sharing (Cors)- See Also:
-
SpincastFilters#cors(R context, Set<String> allowedOrigins, Set<String> extraHeadersAllowedToBeRead, Set<String> extraHeadersAllowedToBeSent)
-
cors
StaticResourceBuilder<R> cors(Set<String> allowedOrigins, Set<String> extraHeadersAllowedToBeRead, Set<String> extraHeadersAllowedToBeSent, boolean allowCookies) Enables Cross-Origin Resource Sharing (Cors)- See Also:
-
SpincastFilters#cors(R context, Set<String> allowedOrigins, Set<String> extraHeadersAllowedToBeRead, Set<String> extraHeadersAllowedToBeSent, boolean allowCookies)
-
cors
StaticResourceBuilder<R> cors(Set<String> allowedOrigins, Set<String> extraHeadersAllowedToBeRead, Set<String> extraHeadersAllowedToBeSent, boolean allowCookies, int maxAgeInSeconds) Enables Cross-Origin Resource Sharing (Cors)- See Also:
-
SpincastFilters#cors(R context, Set<String> allowedOrigins, Set<String> extraHeadersAllowedToBeRead, Set<String> extraHeadersAllowedToBeSent, boolean allowCookies, int maxAgeInSeconds )
-
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.
-
hotlinkingProtected
StaticResourceBuilder<R> hotlinkingProtected()When a static resource is flagged as being *hotlinking protected*, the server will validate theorigin
andreferer
of the request. If those don't matche the host of the application, a protection will be apply, the one provided by the default . -
hotlinkingProtected
When a static resource is flagged as being *hotlinking protected*, the server will validate theorigin
andreferer
of the request. If those don't matche the host of the application, a protection will be apply, the one provided by the specifiedhotlinkingManager
. -
handle
void handle()Saves the static resource route to the router.If the creation of the resource was not started using an
Router
object, an exception will be thrown. -
handle
Saves the static resource route. Note that the generated resource won't be cached if there is a queryString on the request : it will always be generated.If the creation of the resource was not started using an
Router
object, an exception will be thrown.- Parameters:
generator
- If the resource is not found, the specified generator will be used to generate it and the result will be saved.
-
handle
Saves the static resource route.If the creation of the resource was not started using an
Router
object, an exception will be thrown.- Parameters:
generator
- If the resource is not found, the specified generator will be used to generate it and the result will be saved.ignoreQueryString
- Iftrue
, only one instance of the resource will be generated and cached. Iffalse
(the default), the resource will always be generated if there is a queryString.
-
create
StaticResource<R> create()Creates and returns the static resource without adding it to the router. NOTE : usehandle(...)
instead to save the static resource to the router at the end of the build process!
-