Class StaticResourceBinding

java.lang.Object
com.persequor.extension.staticresource.StaticResourceBinding

public class StaticResourceBinding extends Object
  • Field Details

    • rootURI

      public final String rootURI
  • Constructor Details

    • StaticResourceBinding

      public StaticResourceBinding(String rootURI)
  • Method Details

    • to

      public void to(String resourceDirectoryRoot)
      Specifies the root directory in which the resources are stored. NB! Resource folder is not just a folder on the disk, but a Java resource folder which would normally reside inside the jar file, read more here: https://docs.oracle.com/javase/8/docs/technotes/guides/lang/resources.html#res_name_context

      Must be prefixed with '/'.

      Parameters:
      resourceDirectoryRoot - - root directory bound to the URI prefix
    • getResourceDirectoryRoot

      public String getResourceDirectoryRoot()
    • getRootURI

      public String getRootURI()
    • validate

      public void validate()
    • addHeader

      public void addHeader(String headerName, String headerValue)
      Adds a HTTP header to the response when serving this static resource

      If the header already exists, the value will be appended to the existing value

      Parameters:
      headerName - the name of the HTTP header
      headerValue - the value of the HTTP header
    • overrideHeader

      public void overrideHeader(String headerName, String headerValue)
      Overrides a HTTP header to the response when serving this static resource

      If the header already exists, the value will be replaced

      If the header does not exist, it will be added

      Parameters:
      headerName - the name of the HTTP header
      headerValue - the value of the HTTP header
    • getHeaders

      public Map<String,String> getHeaders()
      Returns the HTTP headers to be added to the response when serving this static resource, including any headers added by the system by default, except for the Content-Type header
      Returns:
      an unmodifiable map of HTTP headers