Package io.micronaut.web.router.resource
Class StaticResourceConfiguration
- java.lang.Object
-
- io.micronaut.web.router.resource.StaticResourceConfiguration
-
- All Implemented Interfaces:
io.micronaut.core.util.Toggleable
@EachProperty("micronaut.router.static-resources") public class StaticResourceConfiguration extends java.lang.Object implements io.micronaut.core.util.ToggleableStores configuration for the loading of static resources.- Since:
- 1.0
-
-
Field Summary
Fields Modifier and Type Field Description static booleanDEFAULT_ENABLEDThe default enable value.static java.lang.StringDEFAULT_MAPPINGThe default mapping value.static java.lang.StringPREFIXThe prefix for static resources configuration.
-
Constructor Summary
Constructors Constructor Description StaticResourceConfiguration(io.micronaut.core.io.ResourceResolver resourceResolver, io.micronaut.http.context.ServerContextPathProvider contextPathProvider)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringgetMapping()The static resource mapping.java.util.List<io.micronaut.core.io.ResourceLoader>getResourceLoaders()booleanisEnabled()voidsetEnabled(boolean enabled)Sets whether this specific mapping is enabled.voidsetMapping(java.lang.String mapping)The path resources should be served from.voidsetPaths(java.util.List<java.lang.String> paths)A list of paths either starting with `classpath:` or `file:`.
-
-
-
Field Detail
-
PREFIX
public static final java.lang.String PREFIX
The prefix for static resources configuration.- See Also:
- Constant Field Values
-
DEFAULT_ENABLED
public static final boolean DEFAULT_ENABLED
The default enable value.- See Also:
- Constant Field Values
-
DEFAULT_MAPPING
public static final java.lang.String DEFAULT_MAPPING
The default mapping value.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
StaticResourceConfiguration
public StaticResourceConfiguration(io.micronaut.core.io.ResourceResolver resourceResolver, @Nullable io.micronaut.http.context.ServerContextPathProvider contextPathProvider)- Parameters:
resourceResolver- The ResourceResolvercontextPathProvider- The context path provider
-
-
Method Detail
-
isEnabled
public boolean isEnabled()
- Specified by:
isEnabledin interfaceio.micronaut.core.util.Toggleable- Returns:
- Enable the static resources router
-
getResourceLoaders
public java.util.List<io.micronaut.core.io.ResourceLoader> getResourceLoaders()
- Returns:
- The list of
ResourceLoaderavailable for the path
-
getMapping
public java.lang.String 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
public void setPaths(java.util.List<java.lang.String> paths)
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
public void setMapping(java.lang.String mapping)
The path resources should be served from. Uses ant path matching. Default value ("/**").- Parameters:
mapping- The mapping
-
-