Version 2, last updated by Richard Dallaway at 30 Jan 12:26 UTC
When the container handles requests before Lift
As of: 2.4
Lift can pass some requests to the container, skipping much of the Lift HTTP Pipeline. Typical examples are CSS files, images and Javascript files on disk.
The rules for this are at the servlet filter level, in HTTPProvider.scala where isLiftRequest_? is defined.
In Boot you can declare that certain requests should, or should not, be handled by Lift via the LiftRules.liftRequest mechanism. But let’s assume you have nothing defined in LiftRles.liftRequest. In that case, Lift is going to handle only:
- resources that end in a slash; or
- resources that end
.html,.htm,.xhtml,.xml,.liftjsand.liftcss; or - resources that don’t exist on the file system (i.e., in your WAR because the servlet context lookup returns null).
The last case is the common reason why CSS (and similar) files are served by Lift without needing to be in Sitemap.
A few worked examples of things that Lift will handle (by which I mean, push through it’s pipeline):
Example 1: request for /
| Resource: | / |
| Whole path: | List(index) |
| endSlash: | true |
| Context resource: | /Users/richard/Developer/myapp/ |
| Passed to Lift pipeline? | Yes, because it ends in a slash |
Example 2: request for liftAjax.js
| Resource: | /ajax_request/liftAjax.js |
| Whole path: | List(ajax_request, liftAjax.js) |
| endSlash: | false |
| Context resource: | null |
| Passed to Lift pipeline? | Yes, because it doesn’t exist as a context resource |
Example 3: a HTML file.
| Resource: | /foo.html |
| Whole path: | List(foo.html) |
| endSlash: | false |
| Context resource: | Could be null, or could exist – doesn’t matter |
| Passed to Lift pipeline? | Yes, because has a recognised file ending of .html
|
Example 4: a CSS file
Assume a CSS does exist on the file system, it’ll be handled by the container (and not the Lift pipeline) because it neither ends in a slash nor has one of the special extensions but it does exist on the file system:
| Resource: | /foo.css |
| Whole path: | List(foo.css) |
| endSlash: | false |
| Context resource: | /Users/richard/Developer/myapp/foo.css |
| Passed to Lift pipeline? | No, because it exists on disk and is not a recognized file or index resource |
For foo.css isLiftRequest_? is going to return false, and the decision to chain will get short-circuited in this expression…
if (!(isLiftRequest_?(newReq) && actualServlet.service(newReq, resp))) {
chain
}
… and hence, the Lift servlet won’t get called, so foo.css doesn’t have to be in Sitemap because Sitemap is never reached.