1.2 Simple Single Servlet Servers
The Web Server provides a way to quickly configure and start a server instance.
| ||||||||||||||||||||||||||||||||||||||||||||||||||||
→ void | ||||||||||||||||||||||||||||||||||||||||||||||||||||
servlet : (request? . -> . response?) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
launch-browser? : boolean? = #t | ||||||||||||||||||||||||||||||||||||||||||||||||||||
quit? : boolean? = #t | ||||||||||||||||||||||||||||||||||||||||||||||||||||
listen-ip : string? = "127.0.0.1" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
port : number? = 8000 | ||||||||||||||||||||||||||||||||||||||||||||||||||||
manager : manager? = default-threshold-LRU-manager | ||||||||||||||||||||||||||||||||||||||||||||||||||||
servlet-namespace : (listof module-path?) = empty | ||||||||||||||||||||||||||||||||||||||||||||||||||||
server-root-path : path? = default-server-root-path | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||||||||
servlets-root : path? = (build-path server-root-path ".") | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||||||||
servlet-path : path? = "servlets/standalone.ss" |
This sets up and starts a fairly default server instance.
servlet is installed as a server at servlet-path with manager as its continuation manager. (The default manager limits the amount of memory to 64 MB and deals with memory pressure as discussed in the make-threshold-LRU-manager documentation.)
If launch-browser? is true, then a web browser is opened to the servlet’s start page.
If quit? is true, then the URL "/quit" ends the server.
Advanced users may need the following options:
The server listens on listen-ip and port port.
The modules specified by servlet-namespace are shared with other servlets.
The server files are rooted at server-root-path (which is defaultly the distribution root.) A file path, in addition to the "htdocs" directory under server-root-path may be provided with extra-files-path. These files are checked first. The "servlets" directory is expected at servlets-root.
If a file cannot be found, file-not-found-path is used as an error response.
MIME types are looked up at mime-types-path.