- make MAKE-PATH-PREFIX-HANDLER work right for null paths.

- add our own version of GET-HEADER in preparation for the RFC822 overhaul
This commit is contained in:
sperber 2003-01-20 16:24:29 +00:00
parent 7d91324b9a
commit ef7a21b729
1 changed files with 10 additions and 1 deletions

View File

@ -51,11 +51,20 @@
(string=? hostname (string-trim (get-header (request-headers req) 'host)))) (string=? hostname (string-trim (get-header (request-headers req) 'host))))
handler default-handler)) handler default-handler))
(define (get-header headers tag)
(cond
((assq tag headers) => cdr)
(else
(http-error (status-code bad-request) #f
(string-append "Request did not contain "
(symbol->string tag)
" header")))))
;; selects handler according to path-prefix ;; selects handler according to path-prefix
;; if path-prefix matches, handler is called without the path-prefix ;; if path-prefix matches, handler is called without the path-prefix
(define (make-path-prefix-handler path-prefix handler default-handler) (define (make-path-prefix-handler path-prefix handler default-handler)
(lambda (path req) (lambda (path req)
(if (string=? path-prefix (car path)) (if (and (pair? path) (string=? path-prefix (car path)))
(handler (cdr path) req) (handler (cdr path) req)
(default-handler path req)))) (default-handler path req))))