Closed cpitclaudel closed 8 months ago
We don't support rewrite rules, and I'm not sure we want to. This kind of rewrite rule can really get very confusing, and it really goes against Cask's routing philosophy of having a single tree of endpoints that can be traversed in one pass (v.s. the "try every route in sequence and find one that matches" approach that other frameworks do.
IMO if you want rewrite rules, easiest thing is to just throw nginx in front of your Cask web server. That's what I do in a bunch of places for a variety of reasons, and it works well enough. nginx is a pretty small process and can easily fit inside the same docker container or deployment
For index.html
, I would do
@cask.get("/")
def index() = cask.Response(
os.read(os.Path(STATIC_PATH) / "index.html"),
200,
headers = Seq("Content-Type" -> "text/html; charset=utf-8")
)
Hi,
I'm trying to use case for a very simple website: a few web pages wrapping a simple REST API. My routes look like this:
There are two problems with this approach:
/www/index.html
./www
instead of/
In Apache or nginx I would use a URL rewrite instead to rewrite
/
to/www/
transparently except when the path starts with/api
. I have not found a way to do this in Cask. Hence, I have three questions:/
route, call thestaticFiles
route to get the contents of/www/index.html
?/
queries to/www
, except/api
?staticFiles
route that overlaps with other routes, to be used as a fallback when other routes don't match?The main blocker for me is the
index.html
rewrite; I can live with the non-overlapping routes.Thanks a lot!