diff --git a/scheme/httpd/response.scm b/scheme/httpd/response.scm index 7a7d6f7..d239a2a 100644 --- a/scheme/httpd/response.scm +++ b/scheme/httpd/response.scm @@ -98,6 +98,18 @@ (vector-ref status-codes i)) (else (loop (+ i 1))))))) + +(define (number->status-code number) + (if (not (number? number)) + (call-error number->status-code (list number)) + (let loop ((i 0)) + (cond ((= i (vector-length status-codes)) + #f) + ((= number + (status-code-number (vector-ref status-codes i))) + (vector-ref status-codes i)) + (else + (loop (+ i 1))))))) ;;; (make-error-response status-code req [message . extras]) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; diff --git a/scheme/packages.scm b/scheme/packages.scm index aaa5f96..a649e3e 100644 --- a/scheme/packages.scm +++ b/scheme/packages.scm @@ -286,6 +286,7 @@ status-code-message (status-code :syntax) name->status-code + number->status-code make-error-response make-redirect-response