► |  | Web Server: PLT HTTP Server

1 | Running the Web Server
2 | Writing Servlets
3 | Extending the Web Server
4 | Troubleshooting and Tips
5 | Acknowledgements
| Index

► | 3 | Extending the Web Server

3.1 | Configuration
3.2 | Setting Up Servlets
3.3 | Dispatchers
3.4 | Web Config Unit
3.5 | Web Server Unit
3.6 | Internal

▼ | 3.3 | Dispatchers

3.3.1 | General
3.3.2 | Mapping URLs to Paths
3.3.3 | Sequencing
3.3.4 | Timeouts
3.3.5 | Lifting Procedures
3.3.6 | Filtering Requests
3.3.7 | Procedure Invocation upon Request
3.3.8 | Logging
3.3.9 | Password Protection
3.3.10 | Virtual Hosts
3.3.11 | Serving Files
3.3.12 | Serving Servlets
3.3.13 | Statistics
3.3.14 | Limiting Requests

On this page:

url->path/ c
make-url->path
make-url->valid-path
filter-url->path

Version: 4.1.4
top← prev up next →

##### 3.3.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/c : 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/c
base : path-string?

The url-path/c 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/c
url->path : url->path/c

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.

(filter-url->path regex url->path) → url->path/c
regex : regexp?
url->path : url->path/c

Runs the underlying url->path but will only return if the path, when considered as a string, matches the regex. This is useful to disallow strange files, like GIFs, from being considered servlets when using the servlet dispatchers. It will return a exn:fail:filesystem:exists? exception if the path does not match.

top← prev up next →