Request from Untyped plus new docs
svn: r12235
This commit is contained in:
parent
dfacf40a4c
commit
4b10a33b85
|
@ -9,6 +9,43 @@
|
||||||
|
|
||||||
The @web-server provides a way to quickly configure and start a server instance.
|
The @web-server provides a way to quickly configure and start a server instance.
|
||||||
|
|
||||||
|
Here's a simple example:
|
||||||
|
@schememod[
|
||||||
|
scheme
|
||||||
|
(require web-server/servlet
|
||||||
|
web-server/servlet-env)
|
||||||
|
|
||||||
|
(define (my-app request)
|
||||||
|
`(html (head (title "Hello world!"))
|
||||||
|
(body (p "Hey out there!"))))
|
||||||
|
|
||||||
|
(serve/servlet my-app)
|
||||||
|
]
|
||||||
|
|
||||||
|
Suppose you'd like to change the port to something else, change the last line to:
|
||||||
|
@schemeblock[
|
||||||
|
(serve/servlet my-app
|
||||||
|
#:port 8080)
|
||||||
|
]
|
||||||
|
|
||||||
|
By default the URL for your servlet is @filepath{http://localhost:8000/servlets/standalone.ss},
|
||||||
|
suppose you wanted it to be @filepath{http://localhost:8000/hello.ss}:
|
||||||
|
@schemeblock[
|
||||||
|
(serve/servlet my-app
|
||||||
|
#:servlet-path (build-path "hello.ss"))
|
||||||
|
]
|
||||||
|
For the time being, this path must end in @filepath{.ss} or @filepath{.scm}.
|
||||||
|
|
||||||
|
Suppose you wanted to use a style-sheet (@filepath{style.css}) found on your Desktop (@filepath{/Users/jay/Desktop/}):
|
||||||
|
@schemeblock[
|
||||||
|
(serve/servlet my-app
|
||||||
|
#:extra-files-paths
|
||||||
|
(list
|
||||||
|
(build-path "/Users/jay/Desktop")))
|
||||||
|
]
|
||||||
|
These files are served @emph{in addition} to those from the @scheme[#:server-root-path] @filepath{htdocs} directory.
|
||||||
|
Notice that you may pass any number of extra paths.
|
||||||
|
|
||||||
@defproc[(serve/servlet [servlet (request? . -> . response?)]
|
@defproc[(serve/servlet [servlet (request? . -> . response?)]
|
||||||
[#:launch-browser? launch-browser? boolean? #t]
|
[#:launch-browser? launch-browser? boolean? #t]
|
||||||
[#:quit? quit? boolean? #t]
|
[#:quit? quit? boolean? #t]
|
||||||
|
@ -17,7 +54,7 @@ The @web-server provides a way to quickly configure and start a server instance.
|
||||||
[#:manager manager manager? default-threshold-LRU-manager]
|
[#:manager manager manager? default-threshold-LRU-manager]
|
||||||
[#:servlet-namespace servlet-namespace (listof module-path?) empty]
|
[#:servlet-namespace servlet-namespace (listof module-path?) empty]
|
||||||
[#:server-root-path server-root-path path? default-server-root-path]
|
[#:server-root-path server-root-path path? default-server-root-path]
|
||||||
[#:extra-files-path extra-files-path path? (build-path server-root-path "htdocs")]
|
[#:extra-files-paths extra-files-paths (listof path?) (list (build-path server-root-path "htdocs"))]
|
||||||
[#:servlets-root servlets-root path? (build-path server-root-path ".")]
|
[#:servlets-root servlets-root path? (build-path server-root-path ".")]
|
||||||
[#:file-not-found-path file-not-found-path path?
|
[#:file-not-found-path file-not-found-path path?
|
||||||
(build-path server-root-path "conf" "not-found.html")]
|
(build-path server-root-path "conf" "not-found.html")]
|
||||||
|
@ -43,8 +80,8 @@ The @web-server provides a way to quickly configure and start a server instance.
|
||||||
The modules specified by @scheme[servlet-namespace] are shared with other servlets.
|
The modules specified by @scheme[servlet-namespace] are shared with other servlets.
|
||||||
|
|
||||||
The server files are rooted at @scheme[server-root-path] (which is defaultly the distribution root.)
|
The server files are rooted at @scheme[server-root-path] (which is defaultly the distribution root.)
|
||||||
A file path, in addition to the @filepath["htdocs"] directory under @scheme[server-root-path] may be
|
File paths, in addition to the @filepath["htdocs"] directory under @scheme[server-root-path] may be
|
||||||
provided with @scheme[extra-files-path]. These files are checked first.
|
provided with @scheme[extra-files-paths]. These paths are checked first, in the order they appear in the list.
|
||||||
The @filepath["servlets"] directory is expected at @scheme[servlets-root].
|
The @filepath["servlets"] directory is expected at @scheme[servlets-root].
|
||||||
|
|
||||||
If a file cannot be found, @scheme[file-not-found-path] is used as an error response.
|
If a file cannot be found, @scheme[file-not-found-path] is used as an error response.
|
||||||
|
|
|
@ -48,7 +48,7 @@
|
||||||
#:manager manager?
|
#:manager manager?
|
||||||
#:servlet-namespace (listof module-path?)
|
#:servlet-namespace (listof module-path?)
|
||||||
#:server-root-path path?
|
#:server-root-path path?
|
||||||
#:extra-files-path path?
|
#:extra-files-paths (listof path?)
|
||||||
#:servlets-root path?
|
#:servlets-root path?
|
||||||
#:file-not-found-path path?
|
#:file-not-found-path path?
|
||||||
#:mime-types-path path?
|
#:mime-types-path path?
|
||||||
|
@ -78,8 +78,9 @@
|
||||||
[servlet-namespace empty]
|
[servlet-namespace empty]
|
||||||
#:server-root-path
|
#:server-root-path
|
||||||
[server-root-path (directory-part default-configuration-table-path)]
|
[server-root-path (directory-part default-configuration-table-path)]
|
||||||
#:extra-files-path
|
#:extra-files-paths
|
||||||
[extra-files-path (build-path server-root-path "htdocs")]
|
[extra-files-paths (list (build-path server-root-path "htdocs"))]
|
||||||
|
; XXX Add support for other servlets
|
||||||
#:servlets-root
|
#:servlets-root
|
||||||
[servlets-root (build-path server-root-path ".")]
|
[servlets-root (build-path server-root-path ".")]
|
||||||
#:file-not-found-path
|
#:file-not-found-path
|
||||||
|
@ -112,11 +113,14 @@
|
||||||
(values (build-path servlets-root servlet-path)
|
(values (build-path servlets-root servlet-path)
|
||||||
empty)))])
|
empty)))])
|
||||||
servlet-dispatch))
|
servlet-dispatch))
|
||||||
|
(apply sequencer:make
|
||||||
|
(map (lambda (extra-files-path)
|
||||||
(files:make
|
(files:make
|
||||||
#:url->path (fsmap:make-url->path
|
#:url->path (fsmap:make-url->path
|
||||||
extra-files-path)
|
extra-files-path)
|
||||||
#:path->mime-type (make-path->mime-type mime-types-path)
|
#:path->mime-type (make-path->mime-type mime-types-path)
|
||||||
#:indices (list "index.html" "index.htm"))
|
#:indices (list "index.html" "index.htm")))
|
||||||
|
extra-files-paths))
|
||||||
(files:make
|
(files:make
|
||||||
#:url->path (fsmap:make-url->path
|
#:url->path (fsmap:make-url->path
|
||||||
(build-path server-root-path "htdocs"))
|
(build-path server-root-path "htdocs"))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user