Standardizing names

svn: r6418
This commit is contained in:
Jay McCarthy 2007-05-30 22:01:17 +00:00
parent 6ac2665af9
commit bec7331eae
9 changed files with 64 additions and 74 deletions

View File

@ -8,7 +8,7 @@
(lib "web-server-unit.ss" "web-server") (lib "web-server-unit.ss" "web-server")
(lib "web-server-sig.ss" "web-server") (lib "web-server-sig.ss" "web-server")
(lib "web-config-sig.ss" "web-server") (lib "web-config-sig.ss" "web-server")
(lib "configuration.ss" "web-server") (lib "web-config-unit.ss" "web-server")
(lib "namespace.ss" "web-server" "configuration") (lib "namespace.ss" "web-server" "configuration")
"private/config.ss") "private/config.ss")
@ -58,7 +58,7 @@
(virtual-host-table))) (virtual-host-table)))
(define configuration (define configuration
(load-configuration-sexpr (configuration-table-sexpr->web-config@
config config
#:web-server-root web-dir #:web-server-root web-dir
#:make-servlet-namespace #:make-servlet-namespace

View File

@ -1,6 +1,6 @@
(module config mzscheme (module config mzscheme
(require (lib "file.ss") (require (lib "file.ss")
(lib "configuration.ss" "web-server") (lib "web-config-unit.ss" "web-server")
(lib "dirs.ss" "setup") (lib "dirs.ss" "setup")
(lib "config.ss" "planet") (lib "config.ss" "planet")
"internal-hp.ss") "internal-hp.ss")
@ -42,7 +42,7 @@
(servlet-root ,servlet-root) (servlet-root ,servlet-root)
(mime-types "../../web-server/default-web-root/mime.types") (mime-types "../../web-server/default-web-root/mime.types")
(password-authentication "passwords"))))]) (password-authentication "passwords"))))])
(load-configuration-sexpr (configuration-table-sexpr->web-config@
`((port ,internal-port) `((port ,internal-port)
(max-waiting 40) (max-waiting 40)
(initial-connection-timeout 30) (initial-connection-timeout 30)

View File

@ -1,39 +0,0 @@
(module configuration mzscheme
(require (lib "kw.ss")
(lib "contract.ss"))
(require "private/configuration.ss"
"private/configuration-table-structs.ss"
"private/util.ss"
"private/parse-table.ss"
"web-config-sig.ss")
(define default-configuration-table-path
(build-path (collection-path "web-server") "configuration-table"))
; get-configuration : path -> configuration-table
(define (get-configuration table-file-name)
(parse-configuration-table (call-with-input-file table-file-name read)))
; load-configuration : path -> configuration
(define/kw (load-configuration table-file-name
#:other-keys bct-keys)
(apply load-configuration-sexpr
(call-with-input-file table-file-name read)
#:web-server-root (directory-part table-file-name)
bct-keys))
; load-configuration-sexpr : string? sexp -> configuration
(define/kw (load-configuration-sexpr sexpr
#:key
[web-server-root (directory-part default-configuration-table-path)]
#:other-keys bct-keys)
(apply complete-configuration
web-server-root
(parse-configuration-table sexpr)
bct-keys))
(provide load-configuration
load-configuration-sexpr)
(provide/contract
[get-configuration (path-string? . -> . configuration-table?)]
[default-configuration-table-path path?]))

View File

@ -5,7 +5,7 @@
(lib "list.ss") (lib "list.ss")
(lib "pretty.ss") (lib "pretty.ss")
(lib "file.ss") (lib "file.ss")
(only (lib "configuration.ss" "web-server") (only (lib "web-config-unit.ss" "web-server")
default-configuration-table-path) default-configuration-table-path)
(lib "configuration-table-structs.ss" "web-server" "private") (lib "configuration-table-structs.ss" "web-server" "private")
(lib "parse-table.ss" "web-server" "private") (lib "parse-table.ss" "web-server" "private")

View File

@ -4,10 +4,10 @@
(lib "unit.ss") (lib "unit.ss")
(lib "tcp-sig.ss" "net")) (lib "tcp-sig.ss" "net"))
(require "util.ss" (require "util.ss"
"../web-config-unit.ss"
"../web-config-sig.ss" "../web-config-sig.ss"
"../web-server-unit.ss" "../web-server-unit.ss"
"../web-server-sig.ss" "../web-server-sig.ss")
"../configuration.ss")
(define configuration@ (define configuration@
(parse-command-line (parse-command-line
@ -17,11 +17,11 @@
[("-f" "--configuration-table") [("-f" "--configuration-table")
,(lambda (flag file-name) ,(lambda (flag file-name)
(cond (cond
[(not (file-exists? file-name)) [(not (file-exists? file-name))
(error 'web-server "configuration file ~s not found" file-name)] (error 'web-server "configuration file ~s not found" file-name)]
[(not (memq 'read (file-or-directory-permissions file-name))) [(not (memq 'read (file-or-directory-permissions file-name)))
(error 'web-server "configuration file ~s is not readable" file-name)] (error 'web-server "configuration file ~s is not readable" file-name)]
[else (cons 'config (string->path file-name))])) [else (cons 'config (string->path file-name))]))
("Use an alternate configuration table" "file-name")] ("Use an alternate configuration table" "file-name")]
[("-p" "--port") [("-p" "--port")
,(lambda (flag port) ,(lambda (flag port)
@ -43,7 +43,7 @@
(error 'web-server "ip-address expects a numeric ip-address (i.e. 127.0.0.1); given ~s" ip-address)))) (error 'web-server "ip-address expects a numeric ip-address (i.e. 127.0.0.1); given ~s" ip-address))))
("Restrict access to come from ip-address" "ip-address")])) ("Restrict access to come from ip-address" "ip-address")]))
(lambda (flags) (lambda (flags)
(load-configuration (configuration-table->web-config@
(extract-flag 'config flags default-configuration-table-path) (extract-flag 'config flags default-configuration-table-path)
#:port (extract-flag 'port flags #f) #:port (extract-flag 'port flags #f)
#:listen-ip (extract-flag 'ip-address flags #f))) #:listen-ip (extract-flag 'ip-address flags #f)))

View File

@ -2,7 +2,7 @@
(require (lib "cmdline.ss") (require (lib "cmdline.ss")
(lib "file.ss") (lib "file.ss")
(lib "struct.ss")) (lib "struct.ss"))
(require "../configuration.ss" (require "../web-config-unit.ss"
"configuration-table-structs.ss" "configuration-table-structs.ss"
"util.ss" "util.ss"
"configuration-util.ss") "configuration-util.ss")
@ -35,7 +35,7 @@
;; Write configuration-table into dest/configuration-table ;; Write configuration-table into dest/configuration-table
(write-configuration-table (write-configuration-table
(copy-struct configuration-table (copy-struct configuration-table
(get-configuration default-configuration-table-path) (read-configuration-table default-configuration-table-path)
[configuration-table-port port]) [configuration-table-port port])
(build-path dest "configuration-table")))) (build-path dest "configuration-table"))))
'())) '()))

View File

@ -1,8 +1,8 @@
(module servlet-env mzscheme (module servlet-env mzscheme
(require (lib "sendurl.ss" "net") (require (lib "sendurl.ss" "net")
(lib "unit.ss")) (lib "unit.ss"))
(require "../configuration.ss" (require "../web-server.ss"
"../web-server.ss" "../web-config-unit.ss"
"../web-config-sig.ss" "../web-config-sig.ss"
"../private/util.ss" "../private/util.ss"
"../response-structs.ss" "../response-structs.ss"
@ -54,7 +54,7 @@
final-value)) final-value))
(define (build-standalone-servlet-configuration the-port the-path the-servlet) (define (build-standalone-servlet-configuration the-port the-path the-servlet)
(let ([basic-configuration@ (load-configuration default-configuration-table-path)] (let ([basic-configuration@ (configuration-table->web-config@ default-configuration-table-path)]
[the-scripts (make-cache-table)]) [the-scripts (make-cache-table)])
(define-values/invoke-unit basic-configuration@ (define-values/invoke-unit basic-configuration@
(import) (import)

View File

@ -1,12 +1,44 @@
(module configuration mzscheme (module web-config-unit mzscheme
(require (lib "unit.ss") (require (lib "unit.ss")
(lib "kw.ss")) (lib "kw.ss")
(require "configuration-table-structs.ss" (lib "contract.ss"))
"util.ss" (require "private/configuration-table-structs.ss"
"cache-table.ss" "private/util.ss"
"../configuration/namespace.ss" "private/cache-table.ss"
"../configuration/responders.ss" "private/parse-table.ss"
"../web-config-sig.ss") "configuration/namespace.ss"
"configuration/responders.ss"
"web-config-sig.ss")
(provide configuration-table->web-config@
configuration-table-sexpr->web-config@)
(provide/contract
[read-configuration-table (path-string? . -> . configuration-table?)]
[default-configuration-table-path path?])
(define default-configuration-table-path
(build-path (collection-path "web-server") "configuration-table"))
; read-configuration-table : path -> configuration-table
(define (read-configuration-table table-file-name)
(parse-configuration-table (call-with-input-file table-file-name read)))
; configuration-table->web-config@ : path -> configuration
(define/kw (configuration-table->web-config@ table-file-name
#:other-keys bct-keys)
(apply configuration-table-sexpr->web-config@
(call-with-input-file table-file-name read)
#:web-server-root (directory-part table-file-name)
bct-keys))
; configuration-table-sexpr->web-config@ : string? sexp -> configuration
(define/kw (configuration-table-sexpr->web-config@ sexpr
#:key
[web-server-root (directory-part default-configuration-table-path)]
#:other-keys bct-keys)
(apply complete-configuration
web-server-root
(parse-configuration-table sexpr)
bct-keys))
; : str configuration-table -> configuration ; : str configuration-table -> configuration
(define/kw (complete-configuration base table (define/kw (complete-configuration base table
@ -94,6 +126,4 @@
(and (regexp-match (car x) host-name-possibly-followed-by-a-collon-and-a-port-number) (and (regexp-match (car x) host-name-possibly-followed-by-a-collon-and-a-port-number)
(cadr x))) (cadr x)))
expanded-virtual-host-table) expanded-virtual-host-table)
default-host))) default-host))))
(provide complete-configuration))

View File

@ -10,7 +10,6 @@
"web-config-sig.ss" "web-config-sig.ss"
"web-server-sig.ss" "web-server-sig.ss"
"web-server-unit.ss" "web-server-unit.ss"
"configuration.ss"
(prefix http: "private/request.ss")) (prefix http: "private/request.ss"))
(provide (provide
serve serve