public interface StaticResourceBuilder<R extends RequestContext<?>>
| Modifier and Type | Method and Description |
|---|---|
StaticResourceBuilder<R> |
cache(int seconds)
Adds public cache headers.
|
StaticResourceBuilder<R> |
cache(int seconds,
boolean isPrivate)
Adds cache headers.
|
StaticResourceBuilder<R> |
cache(int seconds,
boolean isPrivate,
Integer secondsCdn)
Adds cache headers.
|
StaticResourceBuilder<R> |
classpath(String path)
The path to the resource, on the classpath.
|
StaticResourceBuilder<R> |
cors()
Enables Cross-Origin Resource Sharing (Cors)
|
StaticResourceBuilder<R> |
cors(Set<String> allowedOrigins)
Enables Cross-Origin Resource Sharing (Cors)
|
StaticResourceBuilder<R> |
cors(Set<String> allowedOrigins,
Set<String> extraHeadersAllowedToBeRead)
Enables Cross-Origin Resource Sharing (Cors)
|
StaticResourceBuilder<R> |
cors(Set<String> allowedOrigins,
Set<String> extraHeadersAllowedToBeRead,
Set<String> extraHeadersAllowedToBeSent)
Enables Cross-Origin Resource Sharing (Cors)
|
StaticResourceBuilder<R> |
cors(Set<String> allowedOrigins,
Set<String> extraHeadersAllowedToBeRead,
Set<String> extraHeadersAllowedToBeSent,
boolean allowCookies)
Enables Cross-Origin Resource Sharing (Cors)
|
StaticResourceBuilder<R> |
cors(Set<String> allowedOrigins,
Set<String> extraHeadersAllowedToBeRead,
Set<String> extraHeadersAllowedToBeSent,
boolean allowCookies,
int maxAgeInSeconds)
Enables Cross-Origin Resource Sharing (Cors)
|
StaticResource<R> |
create()
Creates and returns the static resource without adding it to
the router.
|
void |
handle()
Saves the static resource route to the router.
|
void |
handle(Handler<R> generator)
Saves the static resource route.
|
void |
handle(Handler<R> generator,
boolean ignoreQueryString)
Saves the static resource route.
|
StaticResourceBuilder<R> |
hotlinkingProtected()
When a static resource is flagged as being
*hotlinking protected*, the server will
validate the
origin and referer
of the request. |
StaticResourceBuilder<R> |
hotlinkingProtected(HotlinkingManager hotlinkingManager)
When a static resource is flagged as being
*hotlinking protected*, the server will
validate the
origin and referer
of the request. |
StaticResourceBuilder<R> |
pathAbsolute(String absolutePath)
The absolute path to the resource, on the file system.
|
StaticResourceBuilder<R> |
pathRelative(String relativePath)
The path to the resource, on the file system, relative to the
temp Spincast directory, as returned by
SpincastConfig::getSpincastTempDir() |
StaticResourceBuilder<R> |
spicastOrPluginAddedResource()
This should only by called by *plugins*.
|
StaticResourceBuilder<R> |
url(String url)
The URL pointing to the resource.
|
StaticResourceBuilder<R> spicastOrPluginAddedResource()
When this method is called, the resulting route for
the resource won't
be remove by default when the
Router.removeAllRoutes() method is used. The
Router.removeAllRoutes(boolean) with true
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.
StaticResourceBuilder<R> url(String url)
StaticResourceBuilder<R> classpath(String path)
StaticResourceBuilder<R> pathAbsolute(String absolutePath)
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
correct Content-Type to be sent!StaticResourceBuilder<R> pathRelative(String relativePath)
SpincastConfig::getSpincastTempDir()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
correct Content-Type to be sent!StaticResourceBuilder<R> cors()
SpincastFilters#cors(R context)StaticResourceBuilder<R> cors(Set<String> allowedOrigins)
SpincastFilters#cors(R context,
Set<String> allowedOrigins)StaticResourceBuilder<R> cors(Set<String> allowedOrigins, Set<String> extraHeadersAllowedToBeRead)
SpincastFilters#cors(R context,
Set<String> allowedOrigins,
Set<String> extraHeadersAllowedToBeRead)StaticResourceBuilder<R> cors(Set<String> allowedOrigins, Set<String> extraHeadersAllowedToBeRead, Set<String> extraHeadersAllowedToBeSent)
SpincastFilters#cors(R context,
Set<String> allowedOrigins,
Set<String> extraHeadersAllowedToBeRead,
Set<String> extraHeadersAllowedToBeSent)StaticResourceBuilder<R> cors(Set<String> allowedOrigins, Set<String> extraHeadersAllowedToBeRead, Set<String> extraHeadersAllowedToBeSent, boolean allowCookies)
SpincastFilters#cors(R context,
Set<String> allowedOrigins,
Set<String> extraHeadersAllowedToBeRead,
Set<String> extraHeadersAllowedToBeSent,
boolean allowCookies)StaticResourceBuilder<R> cors(Set<String> allowedOrigins, Set<String> extraHeadersAllowedToBeRead, Set<String> extraHeadersAllowedToBeSent, boolean allowCookies, int maxAgeInSeconds)
SpincastFilters#cors(R context,
Set<String> allowedOrigins,
Set<String> extraHeadersAllowedToBeRead,
Set<String> extraHeadersAllowedToBeSent,
boolean allowCookies,
int maxAgeInSeconds
)StaticResourceBuilder<R> cache(int seconds)
seconds - The number of seconds the resource associated with
this route should be cached.StaticResourceBuilder<R> cache(int seconds, boolean isPrivate)
seconds - The number of seconds the resource associated with
this route should be cached.isPrivate - should the cache be private?
(help)StaticResourceBuilder<R> cache(int seconds, boolean isPrivate, Integer secondsCdn)
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. If null, it
won't be used.StaticResourceBuilder<R> hotlinkingProtected()
origin and referer
of the request. If those don't matche the host of the
application, a protection will be apply, the one provided
by the default .StaticResourceBuilder<R> hotlinkingProtected(HotlinkingManager hotlinkingManager)
origin and referer
of the request. If those don't matche the host of the
application, a protection will be apply, the one provided
by the specified hotlinkingManager.void handle()
If the creation of the resource was not started using
an Router object, an exception will be
thrown.
void handle(Handler<R> generator)
If the creation of the resource was not started using
an Router object, an exception will be
thrown.
generator - If the resource is not found, the specified
generator will be used to generate it and
the result will be saved.void handle(Handler<R> generator, boolean ignoreQueryString)
If the creation of the resource was not started using
an Router object, an exception will be
thrown.
generator - If the resource is not found, the specified
generator will be used to generate it and
the result will be saved.ignoreQueryString - If true, only one
instance of the resource will be generated and cached. If
false (the default), the resource will always be
generated if there is a queryString.StaticResource<R> create()
handle(...) instead to save the static resource
to the router at the end of the build process!Copyright © 2019. All rights reserved.