public class StaticResourceBuilder<R extends IRequestContext<?>,W extends IWebsocketContext<?>> extends Object implements IStaticResourceBuilder<R>
| Modifier and Type | Field and Description |
|---|---|
protected org.slf4j.Logger |
logger |
| Constructor and Description |
|---|
StaticResourceBuilder(boolean isDir,
IStaticResourceFactory<R> staticResourceFactory,
IStaticResourceCorsConfigFactory staticResourceCorsConfigFactory,
IStaticResourceCacheConfigFactory staticResourceCacheConfigFactory,
ISpincastConfig spincastConfig,
ISpincastUtils spincastUtils,
ISpincastRouterConfig spincastRouterConfig) |
StaticResourceBuilder(IRouter<R,W> router,
boolean isDir,
IStaticResourceFactory<R> staticResourceFactory,
IStaticResourceCorsConfigFactory staticResourceCorsConfigFactory,
IStaticResourceCacheConfigFactory staticResourceCacheConfigFactory,
ISpincastConfig spincastConfig,
ISpincastUtils spincastUtils,
ISpincastRouterConfig spincastRouterConfig) |
| Modifier and Type | Method and Description |
|---|---|
IStaticResourceBuilder<R> |
cache(int seconds)
Adds public cache headers.
|
IStaticResourceBuilder<R> |
cache(int seconds,
boolean isCachePrivate)
Adds cache headers.
|
IStaticResourceBuilder<R> |
cache(int seconds,
boolean isCachePrivate,
Integer cdnSeconds)
Adds cache headers.
|
IStaticResourceBuilder<R> |
classpath(String path)
The path to the resource, on the classpath.
|
IStaticResourceBuilder<R> |
cors()
Enables Cross-Origin Resource Sharing (Cors)
|
IStaticResourceBuilder<R> |
cors(Set<String> allowedOrigins)
Enables Cross-Origin Resource Sharing (Cors)
|
IStaticResourceBuilder<R> |
cors(Set<String> allowedOrigins,
Set<String> extraHeadersAllowedToBeRead)
Enables Cross-Origin Resource Sharing (Cors)
|
IStaticResourceBuilder<R> |
cors(Set<String> allowedOrigins,
Set<String> extraHeadersAllowedToBeRead,
Set<String> extraHeadersAllowedToBeSent)
Enables Cross-Origin Resource Sharing (Cors)
|
IStaticResourceBuilder<R> |
cors(Set<String> allowedOrigins,
Set<String> extraHeadersAllowedToBeRead,
Set<String> extraHeadersAllowedToBeSent,
boolean allowCookies)
Enables Cross-Origin Resource Sharing (Cors)
|
IStaticResourceBuilder<R> |
cors(Set<String> allowedOrigins,
Set<String> extraHeadersAllowedToBeRead,
Set<String> extraHeadersAllowedToBeSent,
boolean allowCookies,
int maxAgeInSeconds)
Enables Cross-Origin Resource Sharing (Cors)
|
IStaticResource<R> |
create()
Creates and returns the static resource without adding it to
the router.
|
protected Integer |
getCacheCdnSecondsDefault() |
IStaticResourceCacheConfig |
getCacheConfig() |
IStaticResourceCorsConfig |
getCorsConfig() |
protected Set<String> |
getCorsDefaultAllowedOrigins()
The origins allowed, by default.
|
protected Set<String> |
getCorsDefaultExtraHeadersAllowedToBeRead()
The extra headers allowed to be read, by default,
|
protected Set<String> |
getCorsDefaultExtraHeadersAllowedToBeSent()
The extra headers allowed to be sent, by default,
|
protected boolean |
getCorsDefaultIsCookiesAllowed()
Are cookies allowed by default?
|
protected int |
getCorsDefaultMaxAgeInSeconds()
If <= 0, the "Access-Control-Max-Age" header
won't be sent.
|
protected IStaticResourceCacheConfig |
getDefaultCacheConfig()
The default cache configurations to use if it is
not specified.
|
IHandler<R> |
getGenerator() |
String |
getPath() |
protected IRouter<R,W> |
getRouter() |
protected ISpincastConfig |
getSpincastConfig() |
protected ISpincastRouterConfig |
getSpincastRouterConfig() |
protected ISpincastUtils |
getSpincastUtils() |
protected IStaticResourceCacheConfigFactory |
getStaticResourceCacheConfigFactory() |
protected IStaticResourceCorsConfigFactory |
getStaticResourceCorsConfigFactory() |
protected IStaticResourceFactory<R> |
getStaticResourceFactory() |
String |
getUrl() |
protected boolean |
isCachePrivateDefault()
Is the cache private by default?
|
boolean |
isClasspath() |
protected boolean |
isDir() |
IStaticResourceBuilder<R> |
pathAbsolute(String absolutePath)
The absolute path to the resource, on the file system.
|
IStaticResourceBuilder<R> |
pathRelative(String relativePath)
The path to the resource, on the file system, relative to the
temp Spincast directory, as returned by
ISpincastConfig::getSpincastTempDir() |
void |
save()
Saves the static resource route to the router.
|
void |
save(IHandler<R> generator)
Saves the static resource route.
|
IStaticResourceBuilder<R> |
url(String url)
The URL pointing to the resource.
|
public StaticResourceBuilder(boolean isDir,
IStaticResourceFactory<R> staticResourceFactory,
IStaticResourceCorsConfigFactory staticResourceCorsConfigFactory,
IStaticResourceCacheConfigFactory staticResourceCacheConfigFactory,
ISpincastConfig spincastConfig,
ISpincastUtils spincastUtils,
ISpincastRouterConfig spincastRouterConfig)
public StaticResourceBuilder(IRouter<R,W> router, boolean isDir, IStaticResourceFactory<R> staticResourceFactory, IStaticResourceCorsConfigFactory staticResourceCorsConfigFactory, IStaticResourceCacheConfigFactory staticResourceCacheConfigFactory, ISpincastConfig spincastConfig, ISpincastUtils spincastUtils, ISpincastRouterConfig spincastRouterConfig)
protected boolean isDir()
protected IStaticResourceFactory<R> getStaticResourceFactory()
protected IStaticResourceCorsConfigFactory getStaticResourceCorsConfigFactory()
protected IStaticResourceCacheConfigFactory getStaticResourceCacheConfigFactory()
protected ISpincastConfig getSpincastConfig()
protected ISpincastUtils getSpincastUtils()
protected ISpincastRouterConfig getSpincastRouterConfig()
public String getUrl()
public String getPath()
public boolean isClasspath()
public IStaticResourceCorsConfig getCorsConfig()
public IStaticResourceCacheConfig getCacheConfig()
public IStaticResourceBuilder<R> url(String url)
IStaticResourceBuilderurl in interface IStaticResourceBuilder<R extends IRequestContext<?>>public IStaticResourceBuilder<R> classpath(String path)
IStaticResourceBuilderclasspath in interface IStaticResourceBuilder<R extends IRequestContext<?>>public IStaticResourceBuilder<R> pathAbsolute(String absolutePath)
IStaticResourceBuilderpathAbsolute in interface IStaticResourceBuilder<R extends IRequestContext<?>>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!public IStaticResourceBuilder<R> pathRelative(String relativePath)
IStaticResourceBuilderISpincastConfig::getSpincastTempDir()pathRelative in interface IStaticResourceBuilder<R extends IRequestContext<?>>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!public IStaticResourceBuilder<R> cors()
IStaticResourceBuildercors in interface IStaticResourceBuilder<R extends IRequestContext<?>>ISpincastFilters#cors(R context)public IStaticResourceBuilder<R> cors(Set<String> allowedOrigins)
IStaticResourceBuildercors in interface IStaticResourceBuilder<R extends IRequestContext<?>>ISpincastFilters#cors(R context,
Set<String> allowedOrigins)public IStaticResourceBuilder<R> cors(Set<String> allowedOrigins, Set<String> extraHeadersAllowedToBeRead)
IStaticResourceBuildercors in interface IStaticResourceBuilder<R extends IRequestContext<?>>ISpincastFilters#cors(R context,
Set<String> allowedOrigins,
Set<String> extraHeadersAllowedToBeRead)public IStaticResourceBuilder<R> cors(Set<String> allowedOrigins, Set<String> extraHeadersAllowedToBeRead, Set<String> extraHeadersAllowedToBeSent)
IStaticResourceBuildercors in interface IStaticResourceBuilder<R extends IRequestContext<?>>ISpincastFilters#cors(R context,
Set<String> allowedOrigins,
Set<String> extraHeadersAllowedToBeRead,
Set<String> extraHeadersAllowedToBeSent)public IStaticResourceBuilder<R> cors(Set<String> allowedOrigins, Set<String> extraHeadersAllowedToBeRead, Set<String> extraHeadersAllowedToBeSent, boolean allowCookies)
IStaticResourceBuildercors in interface IStaticResourceBuilder<R extends IRequestContext<?>>ISpincastFilters#cors(R context,
Set<String> allowedOrigins,
Set<String> extraHeadersAllowedToBeRead,
Set<String> extraHeadersAllowedToBeSent,
boolean allowCookies)public IStaticResourceBuilder<R> cors(Set<String> allowedOrigins, Set<String> extraHeadersAllowedToBeRead, Set<String> extraHeadersAllowedToBeSent, boolean allowCookies, int maxAgeInSeconds)
IStaticResourceBuildercors in interface IStaticResourceBuilder<R extends IRequestContext<?>>ISpincastFilters#cors(R context,
Set<String> allowedOrigins,
Set<String> extraHeadersAllowedToBeRead,
Set<String> extraHeadersAllowedToBeSent,
boolean allowCookies,
int maxAgeInSeconds
)protected int getCorsDefaultMaxAgeInSeconds()
protected Set<String> getCorsDefaultAllowedOrigins()
protected Set<String> getCorsDefaultExtraHeadersAllowedToBeRead()
protected Set<String> getCorsDefaultExtraHeadersAllowedToBeSent()
protected boolean getCorsDefaultIsCookiesAllowed()
protected boolean isCachePrivateDefault()
protected Integer getCacheCdnSecondsDefault()
public IStaticResourceBuilder<R> cache(int seconds)
IStaticResourceBuildercache in interface IStaticResourceBuilder<R extends IRequestContext<?>>seconds - The number of seconds the resource associated with
this route should be cached.public IStaticResourceBuilder<R> cache(int seconds, boolean isCachePrivate)
IStaticResourceBuildercache in interface IStaticResourceBuilder<R extends IRequestContext<?>>seconds - The number of seconds the resource associated with
this route should be cached.isCachePrivate - should the cache be private?
(help)public IStaticResourceBuilder<R> cache(int seconds, boolean isCachePrivate, Integer cdnSeconds)
IStaticResourceBuildercache in interface IStaticResourceBuilder<R extends IRequestContext<?>>seconds - The number of seconds the resource associated with
this route should be cached.isCachePrivate - should the cache be private?
(help)cdnSeconds - The number of seconds the resource associated with
this route should be cached by a CDN/proxy. If null, it
won't be used.public void save()
IStaticResourceBuilderIRouter object, an exception will be
thrown.save in interface IStaticResourceBuilder<R extends IRequestContext<?>>public void save(IHandler<R> generator)
IStaticResourceBuilderIRouter object, an exception will be
thrown.save in interface IStaticResourceBuilder<R extends IRequestContext<?>>generator - If the resource is not found, the specified
generator will be used to generate it and
the result will be saved.public IStaticResource<R> create()
IStaticResourceBuildersave(...) instead to save the static resource
to the router at the end of the build process!create in interface IStaticResourceBuilder<R extends IRequestContext<?>>protected IStaticResourceCacheConfig getDefaultCacheConfig()
null and,
in that case, no cache header will be used.Copyright © 2016. All rights reserved.