Serving Static Content

Previous knowledge of Properties may be required.

Main

Mandarine allows you to configure & server static content in order to provide a straight forward way to access resources your web application may have.

Static Content

By default, Mandarine will serve resolve static contents that are found in the folder ./src/main/resources/static. These resources will be processed in the root of your web application url. For example, if you have a file in your static folder called mycss.css, and you need to access it, you would request http://yourUrl:yourPort/mycss.css. Note that files inside directories are also allowed.

Setting Your Own Configuration

If you wish to set your own behavior for serving your static content, you can customize it by overriding the default properties in your properties.json.

{
    "mandarine": {
            "resources": {
                "staticFolder": "./src/main/resources/static",
                "staticRegExpPattern": "/(.*)",
                "staticIndex": null,
            }
    }
} 
  • staticFolder

    • Folder where your static resources are located

  • staticRegExpPattern

    • Regular Expression of URL request to match & intercept in order to serve static content.

      • By default, it is set to /(.*) , this means it will be intercepted in the root of your web application as described before as /static/(.*) would serve http://yourUrl:yourPort/static/ for instance.

  • staticIndex

    • Path of index file to be served when requesting the root of the static content (Inside staticFolder).

Cors

Mandarine does not implement any CORS middleware for static content by default. This behavior must be added through the use of Resource Handlers or through the use of properties.

{
    "mandarine": {
        "resources": {
            "cors": {
                "origin": "http://myweb.com",
                ...
            }
        }
    }
}

Last updated