Class 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.Toggleable
    Stores configuration for the loading of static resources.
    Since:
    1.0
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static boolean DEFAULT_ENABLED
      The default enable value.
      static java.lang.String DEFAULT_MAPPING
      The default mapping value.
      static java.lang.String PREFIX
      The 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.String getMapping()
      The static resource mapping.
      java.util.List<io.micronaut.core.io.ResourceLoader> getResourceLoaders()  
      boolean isEnabled()  
      void setEnabled​(boolean enabled)
      Sets whether this specific mapping is enabled.
      void setMapping​(java.lang.String mapping)
      The path resources should be served from.
      void setPaths​(java.util.List<java.lang.String> paths)
      A list of paths either starting with `classpath:` or `file:`.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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 ResourceResolver
        contextPathProvider - The context path provider
    • Method Detail

      • isEnabled

        public boolean isEnabled()
        Specified by:
        isEnabled in interface io.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 ResourceLoader available 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