5 ;;; 8sync --- Asynchronous programming for Guile
6 ;;; Copyright (C) 2015 Christopher Allan Webber <cwebber@dustycloud.org>
8 ;;; This file is part of 8sync.
10 ;;; 8sync is free software: you can redistribute it and/or modify it
11 ;;; under the terms of the GNU Lesser General Public License as
12 ;;; published by the Free Software Foundation, either version 3 of the
13 ;;; License, or (at your option) any later version.
15 ;;; 8sync is distributed in the hope that it will be useful,
16 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;;; GNU Lesser General Public License for more details.
20 ;;; You should have received a copy of the GNU Lesser General Public
21 ;;; License along with 8sync. If not, see <http://www.gnu.org/licenses/>.
23 (use-modules (8sync systems web)
34 (define (simple-404 request request-body)
35 (values (build-response
37 #:headers '((content-type . (text/plain))))
38 "Not found. Dag, yo."))
45 (define (hello-world-view request request-body)
46 (values '((content-type . (text/plain)))
51 ;;; Dispatch / routing
52 ;;; ==================
54 (define (web-dispatch request request-body)
55 (define (call-view view)
56 (view request request-body))
58 (match (split-and-decode-uri-path (uri-path (request-uri request)))
59 ;; This is for the `/' root
60 (() (call-view hello-world-view))
61 ;; An example of an inline view at `/pants/'
63 (values '((content-type . (text/plain)))
66 (call-view simple-404))))
73 (define main (make-web-demo-cli #:handler (wrap-apply web-dispatch)))