Update domain name to kpe.io
[cl-modlisp.git] / utils.lisp
index 2f3a2139186f2398291f568f01d12a34f3141731..bab76c36b97e199c4b35e941c7ad54da85c53949 100644 (file)
 
 (in-package #:modlisp)
 
+(defun format->string (fmt)
+  (case fmt
+    (:html "text/html")
+    (:xml "text/xml")
+    (:text "text/plain")
+    (otherwise fmt)))
+
 (defun format-string (fmt headers)
  `(("Content-Type" .
-    ,(case fmt
-      (:html "text/html")
-      (:xml "text/xml")
-      (:text "text/plain")
-      (otherwise fmt)))
+    ,(format->string fmt))
    . ,headers))
 
 (defmacro write-response ((&key headers len (status "200 OK")) &body body)
@@ -39,7 +42,7 @@
         ,result))))
 
 (defmacro with-ml-page ((&key (format :html) (precompute t) headers)
-                       &body body)
+                        &body body)
   (if precompute
     `(output-ml-page ,format (with-output-to-string (*modlisp-socket*) ,@body) :headers ,headers)
     `(write-response (:headers (format-string ,format ,headers)) ,@body)))
   (when posted-string
     (let ((alist '()))
       (dolist (name=val (kmrcl:delimited-string-to-list posted-string #\&)
-              (nreverse alist))
-       (let ((name-val-list (kmrcl:delimited-string-to-list name=val #\=)))
-         (if (= 2 (length name-val-list))
-           (destructuring-bind (name val) name-val-list
-             (push (cons (if keyword
-                             (kmrcl:ensure-keyword name)
-                           name)
-                         (kmrcl:decode-uri-query-string val))
-                   alist))
-           (cmsg-c :debug "Invalid number of #\= in ~S" name-val-list)))))))
+               (nreverse alist))
+        (let ((name-val-list (kmrcl:delimited-string-to-list name=val #\=)))
+          (if (= 2 (length name-val-list))
+            (destructuring-bind (name val) name-val-list
+              (push (cons (if keyword
+                              (kmrcl:ensure-keyword name)
+                            name)
+                          (kmrcl:decode-uri-query-string val))
+                    alist))
+            (cmsg-c :debug "Invalid number of #\= in ~S" name-val-list)))))))