Reputation: 5494
I read through Serving Static Content and am having a brain-block.
I've got a folder /resources/static
. It has static stuff in it. Some of that stuff is index.html, favicon.ico, a css folder, a js folder, etc.
I want it to show up as https://example.org/favicon.ico, https://example.org/ (default to index.html), etc.
All the examples in the Docs are for a site that shows up as https://example.org/static/index.html
I'm not getting the difference between "static", "resource", "resources", "files"
routing {
static("static") {
files("css")
files("js")
file("image.png")
file("random.txt", "image.png")
default("index.html")
}
}
Upvotes: 0
Views: 499
Reputation: 950
static("static") - this is saying that when a client requests [your_host]/static then use the static handler to deal with the request. Each of the configured handlers will run in order until the first one matches, so if no files match the request under the css directory then the next will run.
files("css") - this tells the static handler to look in a folder called css locally to serve the static content (i.e. client asks for [your_host]/static/style.css will get [app_directory]/css/style.css
file("image.png") - this tells the static handler to return the local file to serve the static content (i.e. client asks for [your_host]/static/* will get [app_directory]/image.png
default("index.html") - this will serve the local file [app_directory]/index.html for any request [your_host]/static/*
resource, resources and defaultResource do the same thing but for resources built in to your app, rather than on the file system.
Upvotes: 1
Reputation: 5494
This MAY have done it.
static("/") {
resources(resourcePackage = "static")
}
defaultResource(resource = "index.html", resourcePackage = "static")
Upvotes: 0