From 3b71e57e3b84f750ee7c5398486f25e51473d00d Mon Sep 17 00:00:00 2001 From: Jay McCarthy Date: Sat, 2 Jun 2007 02:30:22 +0000 Subject: [PATCH] Rearranging API svn: r6459 --- .../configuration/configuration-table.ss | 21 ++++++++++++------- collects/web-server/private/configure.ss | 2 +- collects/web-server/web-config-unit.ss | 7 +------ 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/collects/web-server/configuration/configuration-table.ss b/collects/web-server/configuration/configuration-table.ss index dafd726745..852c74fcae 100644 --- a/collects/web-server/configuration/configuration-table.ss +++ b/collects/web-server/configuration/configuration-table.ss @@ -5,8 +5,10 @@ (require "configuration-table-structs.ss" "../servlet/bindings.ss") (provide/contract + [read-configuration-table (path-string? . -> . configuration-table?)] [write-configuration-table (configuration-table? path-string? . -> . void)] - [parse-configuration-table (list? . -> . configuration-table?)]) + [configuration-table->sexpr (configuration-table? . -> . list?)] + [sexpr->configuration-table (list? . -> . configuration-table?)]) (define (get-binding key bindings default) (first (get-binding* key bindings (list default)))) @@ -15,8 +17,11 @@ (with-handlers ([exn? (lambda _ default)]) (extract-binding/single key bindings))) + (define (read-configuration-table table-file-name) + (sexpr->configuration-table (call-with-input-file table-file-name read))) + ; parse-configuration-table : tst -> configuration-table - (define (parse-configuration-table t) + (define (sexpr->configuration-table t) (define port (get-binding 'port t 80)) (define max-waiting (get-binding 'max-waiting t 40)) (define initial-connection-timeout (get-binding 'initial-connection-timeout t 30)) @@ -78,11 +83,8 @@ mime-types password-authentication))) - ; write-configuration-table : configuration-table path -> void - ; writes out the new configuration file - (define (write-configuration-table new configuration-path) - (define sexpr - `((port ,(configuration-table-port new)) + (define (configuration-table->sexpr new) + `((port ,(configuration-table-port new)) (max-waiting ,(configuration-table-max-waiting new)) (initial-connection-timeout ,(configuration-table-initial-connection-timeout new)) (default-host-table @@ -90,6 +92,11 @@ (virtual-host-table . ,(map (lambda (h) (list (car h) (host-table->sexpr (cdr h)))) (configuration-table-virtual-hosts new))))) + + ; write-configuration-table : configuration-table path -> void + ; writes out the new configuration file + (define (write-configuration-table new configuration-path) + (define sexpr (configuration-table->sexpr new)) (call-with-output-file configuration-path (lambda (out) (pretty-print sexpr out)) 'truncate)) diff --git a/collects/web-server/private/configure.ss b/collects/web-server/private/configure.ss index a6656279d0..1419ded78c 100644 --- a/collects/web-server/private/configure.ss +++ b/collects/web-server/private/configure.ss @@ -694,7 +694,7 @@ ; read-configuration : path -> configuration-table (define (read-configuration configuration-path) - (parse-configuration-table (call-with-input-file configuration-path read))) + (sexpr->configuration-table (call-with-input-file configuration-path read))) ; write-configuration : configuration-table path -> void ; writes out the new configuration file and diff --git a/collects/web-server/web-config-unit.ss b/collects/web-server/web-config-unit.ss index 9f430ed837..797b9f63dd 100644 --- a/collects/web-server/web-config-unit.ss +++ b/collects/web-server/web-config-unit.ss @@ -12,16 +12,11 @@ (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") "default-web-root" "configuration-table.ss")) - ; 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) @@ -37,7 +32,7 @@ #:other-keys bct-keys) (apply complete-configuration web-server-root - (parse-configuration-table sexpr) + (sexpr->configuration-table sexpr) bct-keys)) ; : str configuration-table -> configuration