Mandarine.TS
Latest
Latest
  • Mandarine.TS
  • Getting started
    • Installing Deno Runtime
    • Setting up Environment
    • Quick Example
  • Concepts
  • Mandarine Project Structure
  • Mandarine CLI
    • CLI Reference
      • mandarine new
      • mandarine generate
      • mandarine run
  • Mandarine Core
    • Core Initialization
    • Mandarine.json
    • Dot env file
    • Properties
      • The @Value Decorator
    • Components
      • Controller
      • Middleware
      • Repository
      • Component
      • Service
      • Configuration
      • Manual Component
    • Dependency Injection
      • Accessing DI container
    • Resource Handlers
      • Resource Handler Registry
      • Resource Handler
      • Resource Resolver
  • Mandarine MVC
    • Web MVC
    • Controllers
      • Routes
        • Parameterized Routes
      • HTTP Handlers
      • @ResponseStatus
    • Custom Middleware
    • Session Middleware
    • CORS Middleware
    • Template Engine
      • @Render Decorator
      • Accessing data from template
    • Launching web-app
    • Serving Static Content
    • Multipart Form Data
  • Mandarine Security
    • Sessions
  • Mandarine Data
    • ORM
      • Data source
      • Models
      • Repositories
        • Interacting with data
        • Updating data
    • Mandarine Query Language
  • Resources
    • Changelog
  • Plugins
    • Optional
    • Promise Repeater
Powered by GitBook
On this page
  • Main
  • Static Content
  • Setting Your Own Configuration
  • Cors

Was this helpful?

  1. Mandarine MVC

Serving Static Content

PreviousLaunching web-appNextMultipart Form Data

Last updated 4 years ago

Was this helpful?

Previous knowledge of 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 .

{
    "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": {
        "resources": {
            "cors": {
                "origin": "http://myweb.com",
                ...
            }
        }
    }
}

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

Properties ()

Properties
properties.json
Resource Handlers
properties
See Mandarine.MandarineMVC.CorsMiddlewareOption