X-Git-Url: https://jxself.org/git/?p=8sync.git;a=blobdiff_plain;f=demos%2Fhello-web.scm;fp=demos%2Fhello-web.scm;h=0000000000000000000000000000000000000000;hp=af8bd9d524aa55d6338b76ff7721c8775fea6ff7;hb=60cffdd4c3c7a44d9359e93cf4ae5330158aaf95;hpb=d1d7afdf6d10d021ea79755bb9d3808f67a1c959 diff --git a/demos/hello-web.scm b/demos/hello-web.scm deleted file mode 100755 index af8bd9d..0000000 --- a/demos/hello-web.scm +++ /dev/null @@ -1,73 +0,0 @@ -#!/usr/bin/guile \ --e main -s -!# - -;;; 8sync --- Asynchronous programming for Guile -;;; Copyright (C) 2015 Christopher Allan Webber -;;; -;;; This file is part of 8sync. -;;; -;;; 8sync is free software: you can redistribute it and/or modify it -;;; under the terms of the GNU Lesser General Public License as -;;; published by the Free Software Foundation, either version 3 of the -;;; License, or (at your option) any later version. -;;; -;;; 8sync 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 Lesser General Public License for more details. -;;; -;;; You should have received a copy of the GNU Lesser General Public -;;; License along with 8sync. If not, see . - -(use-modules (8sync systems web) - (8sync agenda) - (web request) - (web response) - (web uri) - (ice-9 match)) - - -;;; Utilities -;;; ========= - -(define (simple-404 request request-body) - (values (build-response - #:code 404 - #:headers '((content-type . (text/plain)))) - "Not found. Dag, yo.")) - - - -;;; Views -;;; ===== - -(define (hello-world-view request request-body) - (values '((content-type . (text/plain))) - "Hello world!")) - - - -;;; Dispatch / routing -;;; ================== - -(define (web-dispatch request request-body) - (define (call-view view) - (view request request-body)) - ;; URI routing here - (match (split-and-decode-uri-path (uri-path (request-uri request))) - ;; This is for the `/' root - (() (call-view hello-world-view)) - ;; An example of an inline view at `/pants/' - (("pants") - (values '((content-type . (text/plain))) - "Hello pants!")) - (_ - (call-view simple-404)))) - - - -;;; CLI -;;; === - -(define main (make-web-demo-cli #:handler (wrap-apply web-dispatch)))