Package io.micronaut.web.router.resource
Class StaticResourceConfiguration
java.lang.Object
io.micronaut.web.router.resource.StaticResourceConfiguration
- All Implemented Interfaces:
Toggleable
@EachProperty("micronaut.router.static-resources")
public class StaticResourceConfiguration
extends Object
implements Toggleable
Stores configuration for the loading of static resources.
- Since:
- 1.0
- Author:
- James Kleeh
-
Field Summary
-
Constructor Summary
ConstructorDescriptionStaticResourceConfiguration
(ResourceResolver resourceResolver, @Nullable ServerContextPathProvider contextPathProvider) -
Method Summary
Modifier and TypeMethodDescriptionThe static resource mapping.boolean
void
setEnabled
(boolean enabled) Sets whether this specific mapping is enabled.void
setMapping
(String mapping) The path resources should be served from.void
A list of paths either starting with `classpath:` or `file:`.
-
Field Details
-
PREFIX
The prefix for static resources configuration.- See Also:
-
DEFAULT_ENABLED
public static final boolean DEFAULT_ENABLEDThe default enable value.- See Also:
-
DEFAULT_MAPPING
The default mapping value.- See Also:
-
-
Constructor Details
-
StaticResourceConfiguration
public StaticResourceConfiguration(ResourceResolver resourceResolver, @Nullable @Nullable ServerContextPathProvider contextPathProvider) - Parameters:
resourceResolver
- The ResourceResolvercontextPathProvider
- The context path provider
-
-
Method Details
-
isEnabled
public boolean isEnabled()- Specified by:
isEnabled
in interfaceToggleable
- Returns:
- Enable the static resources router
-
getResourceLoaders
- Returns:
- The list of
ResourceLoader
available for the path
-
getMapping
The static resource mapping.- Returns:
- The mapping
-
setEnabled
public void setEnabled(boolean enabled) Sets whether this specific mapping is enabled. Default value (true).- Parameters:
enabled
- True if they are enabled.
-
setPaths
A list of paths either starting with `classpath:` or `file:`. You can serve files from anywhere on disk or the classpath. For example to serve static resources from `src/main/resources/public`, you would use `classpath:public` as the path.- Parameters:
paths
- The paths
-
setMapping
The path resources should be served from. Uses ant path matching. Default value ("/**").- Parameters:
mapping
- The mapping
-