I'm going through Lift's basics in Section 3.2 SiteMap
of Simply Lift and one thing struck me.
Using the default SiteMap
code, you can ask for, say, info
view in three ways:
GET /info
,GET /info.html
,GET /info.xml
(why?).What is more, you can request index
view in four different ways:
GET /
,GET /index
,GET /index.html
,GET /index.xml
.How can I limit this behaviour to GET /
for directories and GET /info
for files?
P.S. All of these return 200 OK
:
Shouldn't one resource have one URL only?
There are actually more than four ways that it can be parsed. The full list of known suffixes (any of which can be used to access the page) can be found here.
I think the reason for that is that lift can be used to serve any resource, so most are explicitly added by default.
I think you could disable Lift's processing of all extensions by adding this to Boot.scala
:
LiftRules.explicitlyParsedSuffixes = Nil
However, I wouldn't recommend that as there may be some side-effects.
Using Req
with RestHelper
you can specify the suffix explicitly, but I don't know if there is such a construct to do so with Sitemap
.