diff options
Diffstat (limited to 'weeb/response.scm')
| -rw-r--r-- | weeb/response.scm | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/weeb/response.scm b/weeb/response.scm new file mode 100644 index 0000000..71b8167 --- /dev/null +++ b/weeb/response.scm @@ -0,0 +1,38 @@ +;;; Weeb --- Web microframework for GNU Guile +;;; Copyright © 2026 Jakob Kreuze <zerodaysfordays@sdf.org> +;;; +;;; This file is part of Weeb. +;;; +;;; Weeb is free software: you can redistribute it and/or modify it +;;; under the terms of the GNU Affero General Public License as +;;; published by the Free Software Foundation, either version 3 of the +;;; License, or (at your option) any later version. +;;; +;;; Weeb is distributed in the hope that it will be useful, but WITHOUT +;;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +;;; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General +;;; Public License for more details. +;;; +;;; You should have received a copy of the GNU Affero General Public +;;; License along with Weeb. If not, see <https://www.gnu.org/licenses/>. + +(define-module (weeb response) + #:use-module (ice-9 match) + #:use-module (srfi srfi-1) + #:use-module (srfi srfi-26) + #:use-module (weeb struct) + #:use-module (weeb sxml) + #:export (<response> + any->response)) + +(define-struct <response> + code headers body) + +(define (any->response data) + (match data + ((? (cut instance-of? <> <response>)) data) + ((? string?) (make-struct <response> 200 '() data)) + ((code body) + ;; (assert (and (list? headers) (string? body))) + (make-struct <response> code '() body)) + (_ (error "could not coerce data to <response>" data)))) |