Class StaticResourceBuilderDefault<R extends RequestContext<?>,W extends WebsocketContext<?>>
- All Implemented Interfaces:
StaticResourceBuilder<R>
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionStaticResourceBuilderDefault(boolean isDir, StaticResourceFactory<R> staticResourceFactory, StaticResourceCorsConfigFactory staticResourceCorsConfigFactory, StaticResourceCacheConfigFactory staticResourceCacheConfigFactory, SpincastConfig spincastConfig, SpincastUtils spincastUtils, SpincastRouterConfig spincastRouterConfig) StaticResourceBuilderDefault(Router<R, W> router, boolean isDir, StaticResourceFactory<R> staticResourceFactory, StaticResourceCorsConfigFactory staticResourceCorsConfigFactory, StaticResourceCacheConfigFactory staticResourceCacheConfigFactory, SpincastConfig spincastConfig, SpincastUtils spincastUtils, SpincastRouterConfig spincastRouterConfig) -
Method Summary
Modifier and TypeMethodDescriptioncache(int seconds) Adds public cache headers.cache(int seconds, boolean isCachePrivate) 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.protected IntegerThe origins allowed, by default.The extra headers allowed to be read, by default,The extra headers allowed to be sent, by default,protected booleanAre cookies allowed by default?protected intIf <= 0, the "Access-Control-Max-Age" header won't be sent.protected StaticResourceCacheConfigThe default cache configurations to use if it is not specified.getPath()protected SpincastConfigprotected SpincastRouterConfigprotected SpincastUtilsprotected StaticResourceCacheConfigFactoryprotected StaticResourceCorsConfigFactoryprotected StaticResourceFactory<R>getUrl()voidhandle()Saves the static resource route to the router.voidSaves the static resource route.voidSaves the static resource route.When a static resource is flagged as being *hotlinking protected*, the server will validate theoriginandrefererof the request.hotlinkingProtected(HotlinkingManager hotlinkingManager) When a static resource is flagged as being *hotlinking protected*, the server will validate theoriginandrefererof the request.protected booleanIs the cache private by default?booleanprotected booleanisDir()booleanbooleanprotected booleanpathAbsolute(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.
-
Field Details
-
logger
protected static final org.slf4j.Logger logger
-
-
Constructor Details
-
StaticResourceBuilderDefault
public StaticResourceBuilderDefault(boolean isDir, StaticResourceFactory<R> staticResourceFactory, StaticResourceCorsConfigFactory staticResourceCorsConfigFactory, StaticResourceCacheConfigFactory staticResourceCacheConfigFactory, SpincastConfig spincastConfig, SpincastUtils spincastUtils, SpincastRouterConfig spincastRouterConfig) -
StaticResourceBuilderDefault
public StaticResourceBuilderDefault(Router<R, W> router, boolean isDir, StaticResourceFactory<R> staticResourceFactory, StaticResourceCorsConfigFactory staticResourceCorsConfigFactory, StaticResourceCacheConfigFactory staticResourceCacheConfigFactory, SpincastConfig spincastConfig, SpincastUtils spincastUtils, SpincastRouterConfig spincastRouterConfig)
-
-
Method Details
-
isDir
protected boolean isDir() -
isSpicastOrPluginAddedResource
protected boolean isSpicastOrPluginAddedResource() -
getRouter
-
getStaticResourceFactory
-
getStaticResourceCorsConfigFactory
-
getStaticResourceCacheConfigFactory
-
getSpincastConfig
-
getSpincastUtils
-
getSpincastRouterConfig
-
getUrl
-
getPath
-
isHotlinkingProtected
public boolean isHotlinkingProtected() -
getHotlinkingManager
-
isClasspath
public boolean isClasspath() -
getGenerator
-
getCorsConfig
-
getCacheConfig
-
isIgnoreQueryString
public boolean isIgnoreQueryString() -
spicastOrPluginAddedResource
Description copied from interface:StaticResourceBuilderThis 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)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:
spicastOrPluginAddedResourcein interfaceStaticResourceBuilder<R extends RequestContext<?>>
-
url
Description copied from interface:StaticResourceBuilderThe URL pointing to the resource.- Specified by:
urlin interfaceStaticResourceBuilder<R extends RequestContext<?>>
-
classpath
Description copied from interface:StaticResourceBuilderThe path to the resource, on the classpath.- Specified by:
classpathin interfaceStaticResourceBuilder<R extends RequestContext<?>>
-
pathAbsolute
Description copied from interface:StaticResourceBuilderThe absolute path to the resource, on the file system.- Specified by:
pathAbsolutein interfaceStaticResourceBuilder<R extends RequestContext<?>>- 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-Typeto be sent!
-
pathRelative
Description copied from interface:StaticResourceBuilderThe path to the resource, on the file system, relative to the temp Spincast directory, as returned bySpincastConfig::getSpincastTempDir()- Specified by:
pathRelativein interfaceStaticResourceBuilder<R extends RequestContext<?>>- 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-Typeto be sent!
-
cors
Description copied from interface:StaticResourceBuilderEnables Cross-Origin Resource Sharing (Cors)- Specified by:
corsin interfaceStaticResourceBuilder<R extends RequestContext<?>>- See Also:
-
SpincastFilters#cors(R context)
-
cors
Description copied from interface:StaticResourceBuilderEnables Cross-Origin Resource Sharing (Cors)- Specified by:
corsin interfaceStaticResourceBuilder<R extends RequestContext<?>>- See Also:
-
SpincastFilters#cors(R context, Set<String> allowedOrigins)
-
cors
public StaticResourceBuilder<R> cors(Set<String> allowedOrigins, Set<String> extraHeadersAllowedToBeRead) Description copied from interface:StaticResourceBuilderEnables Cross-Origin Resource Sharing (Cors)- Specified by:
corsin interfaceStaticResourceBuilder<R extends RequestContext<?>>- See Also:
-
SpincastFilters#cors(R context, Set<String> allowedOrigins, Set<String> extraHeadersAllowedToBeRead)
-
cors
public StaticResourceBuilder<R> cors(Set<String> allowedOrigins, Set<String> extraHeadersAllowedToBeRead, Set<String> extraHeadersAllowedToBeSent) Description copied from interface:StaticResourceBuilderEnables Cross-Origin Resource Sharing (Cors)- Specified by:
corsin interfaceStaticResourceBuilder<R extends RequestContext<?>>- See Also:
-
SpincastFilters#cors(R context, Set<String> allowedOrigins, Set<String> extraHeadersAllowedToBeRead, Set<String> extraHeadersAllowedToBeSent)
-
cors
public StaticResourceBuilder<R> cors(Set<String> allowedOrigins, Set<String> extraHeadersAllowedToBeRead, Set<String> extraHeadersAllowedToBeSent, boolean allowCookies) Description copied from interface:StaticResourceBuilderEnables Cross-Origin Resource Sharing (Cors)- Specified by:
corsin interfaceStaticResourceBuilder<R extends RequestContext<?>>- See Also:
-
SpincastFilters#cors(R context, Set<String> allowedOrigins, Set<String> extraHeadersAllowedToBeRead, Set<String> extraHeadersAllowedToBeSent, boolean allowCookies)
-
cors
public StaticResourceBuilder<R> cors(Set<String> allowedOrigins, Set<String> extraHeadersAllowedToBeRead, Set<String> extraHeadersAllowedToBeSent, boolean allowCookies, int maxAgeInSeconds) Description copied from interface:StaticResourceBuilderEnables Cross-Origin Resource Sharing (Cors)- Specified by:
corsin interfaceStaticResourceBuilder<R extends RequestContext<?>>- See Also:
-
SpincastFilters#cors(R context, Set<String> allowedOrigins, Set<String> extraHeadersAllowedToBeRead, Set<String> extraHeadersAllowedToBeSent, boolean allowCookies, int maxAgeInSeconds )
-
getCorsDefaultMaxAgeInSeconds
protected int getCorsDefaultMaxAgeInSeconds()If <= 0, the "Access-Control-Max-Age" header won't be sent. -
getCorsDefaultAllowedOrigins
The origins allowed, by default. -
getCorsDefaultExtraHeadersAllowedToBeRead
The extra headers allowed to be read, by default, -
getCorsDefaultExtraHeadersAllowedToBeSent
The extra headers allowed to be sent, by default, -
getCorsDefaultIsCookiesAllowed
protected boolean getCorsDefaultIsCookiesAllowed()Are cookies allowed by default? -
isCachePrivateDefault
protected boolean isCachePrivateDefault()Is the cache private by default? -
getCacheCdnSecondsDefault
-
cache
Description copied from interface:StaticResourceBuilderAdds public cache headers.- Specified by:
cachein interfaceStaticResourceBuilder<R extends RequestContext<?>>- Parameters:
seconds- The number of seconds the resource associated with this route should be cached.
-
cache
Description copied from interface:StaticResourceBuilderAdds cache headers.- Specified by:
cachein interfaceStaticResourceBuilder<R extends RequestContext<?>>- Parameters:
seconds- The number of seconds the resource associated with this route should be cached.isCachePrivate- should the cache be private? (help)
-
cache
Description copied from interface:StaticResourceBuilderAdds cache headers.- Specified by:
cachein interfaceStaticResourceBuilder<R extends RequestContext<?>>- Parameters:
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. Ifnull, it won't be used.
-
handle
public void handle()Description copied from interface:StaticResourceBuilderSaves the static resource route to the router.If the creation of the resource was not started using an
Routerobject, an exception will be thrown.- Specified by:
handlein interfaceStaticResourceBuilder<R extends RequestContext<?>>
-
handle
Description copied from interface:StaticResourceBuilderSaves 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
Routerobject, an exception will be thrown.- Specified by:
handlein interfaceStaticResourceBuilder<R extends RequestContext<?>>- Parameters:
generator- If the resource is not found, the specified generator will be used to generate it and the result will be saved.
-
handle
Description copied from interface:StaticResourceBuilderSaves the static resource route.If the creation of the resource was not started using an
Routerobject, an exception will be thrown.- Specified by:
handlein interfaceStaticResourceBuilder<R extends RequestContext<?>>- 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
Description copied from interface:StaticResourceBuilderCreates 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!- Specified by:
createin interfaceStaticResourceBuilder<R extends RequestContext<?>>
-
getDefaultCacheConfig
The default cache configurations to use if it is not specified. It can still benulland, in that case, no cache header will be used. -
hotlinkingProtected
Description copied from interface:StaticResourceBuilderWhen a static resource is flagged as being *hotlinking protected*, the server will validate theoriginandrefererof the request. If those don't matche the host of the application, a protection will be apply, the one provided by the default .- Specified by:
hotlinkingProtectedin interfaceStaticResourceBuilder<R extends RequestContext<?>>
-
hotlinkingProtected
Description copied from interface:StaticResourceBuilderWhen a static resource is flagged as being *hotlinking protected*, the server will validate theoriginandrefererof the request. If those don't matche the host of the application, a protection will be apply, the one provided by the specifiedhotlinkingManager.- Specified by:
hotlinkingProtectedin interfaceStaticResourceBuilder<R extends RequestContext<?>>
-