Better docs for serve variants

svn: r12171
This commit is contained in:
Jay McCarthy 2008-10-29 22:21:37 +00:00
parent 2dbeb18164
commit 10127c9561
2 changed files with 15 additions and 21 deletions

View File

@ -1,14 +1,9 @@
#lang scheme/base #lang scheme/base
(require scheme/tcp (require mzlib/cmdline
mzlib/cmdline mzlib/pregexp)
mzlib/pregexp
mzlib/unit
net/tcp-sig)
(require "../configuration/configuration-table.ss" (require "../configuration/configuration-table.ss"
"../web-config-unit.ss" (except-in "../web-server.ss" serve)
"../web-config-sig.ss" "../web-config-unit.ss")
"../web-server-unit.ss"
"../web-server-sig.ss")
; this is used by launchers ; this is used by launchers
; extract-flag : sym (listof (cons sym alpha)) alpha -> alpha ; extract-flag : sym (listof (cons sym alpha)) alpha -> alpha
@ -55,16 +50,7 @@
#:listen-ip (extract-flag 'ip-address flags #f))) #:listen-ip (extract-flag 'ip-address flags #f)))
'())) '()))
(define-compound-unit launch@ (define (serve)
(import (T : tcp^)) (serve/web-config@ configuration@))
(export S)
(link
[((C : web-config^)) configuration@]
[((S : web-server^)) web-server@ T C]))
(define-values/invoke-unit
launch@
(import tcp^)
(export web-server^))
(provide serve) (provide serve)

View File

@ -102,6 +102,8 @@ Here's an example of a simple web server that serves files
from a given path: from a given path:
@(require (for-label web-server/dispatchers/filesystem-map) @(require (for-label web-server/dispatchers/filesystem-map)
(for-label web-server/web-config-unit)
(for-label web-server/web-config-sig)
(prefix-in files: (for-label web-server/dispatchers/dispatch-files))) (prefix-in files: (for-label web-server/dispatchers/dispatch-files)))
@schemeblock[ @schemeblock[
@ -137,8 +139,14 @@ from a given path:
a function that shuts down all of the server instances. a function that shuts down all of the server instances.
} }
@defproc[(serve/web-config@ [config@ web-config^])
(-> void)]{
Starts the @web-server with the settings defined by the given @scheme[web-config^] unit.
It is very useful to combine this with @scheme[configuration-table->web-config@] and @scheme[configuration-table-sexpr->web-config@].
}
@defproc[(do-not-return) void]{ @defproc[(do-not-return) void]{
This function does not return. If you are writing a script to load the @web-server This function does not return. If you are writing a script to load the @web-server
you are likely to want to call this functions at the end of your script. you are likely to want to call this functions at the end of your script.
} }