1 Running the Web Server
2 Scheme Servlets
3 Web Language Servlets
4 Configuration
5 Dispatchers
6 Web Config Unit
7 Web Server Unit
8 Continuation Managers
9 Internal
10 Troubleshooting
11 Acknowledgements
Index
On this page:
url-path?
make-url->path
make-url->valid-path
Version: 4.0.2

 

5.2 Mapping URLs to Paths

 (require web-server/dispatchers/filesystem-map)

"dispatchers/filesystem-map.ss" provides a means of mapping URLs to paths on the filesystem.

url-path? : contract?

This contract is equivalent to (->* (url?) (path? (listof path-element?))). The returned path? is the path on disk. The list is the list of path elements that correspond to the path of the URL.

(make-url->path base)  url-path?

  base : path?

The url-path? returned by this procedure considers the root URL to be base. It ensures that ".."s in the URL do not escape the base and removes them silently otherwise.

(make-url->valid-path url->path)  url->path?

  url->path : url->path?

Runs the underlying url->path, but only returns if the path refers to a file that actually exists. If it is does not, then the suffix elements of the URL are removed until a file is found. If this never occurs, then an error is thrown.

This is primarily useful for dispatchers that allow path information after the name of a service to be used for data, but where the service is represented by a file. The most prominent example is obviously servlets.