From fae20212e660e01b78c1f471777215ada94b5fdc Mon Sep 17 00:00:00 2001 From: Tom Willemse Date: Sat, 13 Jul 2013 02:31:30 +0200 Subject: Deal with json more consistently --- scrumli.lisp | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/scrumli.lisp b/scrumli.lisp index 8ab60f7..f52fff5 100644 --- a/scrumli.lisp +++ b/scrumli.lisp @@ -86,8 +86,7 @@ (define-route stories-json ("stories" :content-type "text/json") (if (logged-in-p) - (with-output-to-string (out) - (encode-json (get-all-stories) out)) + (encode-json-to-string (get-all-stories)) 403)) (defmacro with-post-parameters (parameters &body body) @@ -103,8 +102,7 @@ (with-post-parameters ("role" "necessity" "headline" "content") (post-story role necessity headline content (hunchentoot:session-value :username)) - (with-output-to-string (out) - (encode-json '((status . "ok")) out))) + (encode-json-to-string '((status . "ok")))) 403)) (define-route tasks-new ("stories/tasks/new" :method :post) @@ -128,7 +126,8 @@ (encode-json-to-string `((status . "ok") (state . ,next)))) 403)) -(define-route task-state ("tasks/state" :method :post) +(define-route task-state ("tasks/state" :method :post + :content-type "text/json") (if (logged-in-p) (let* ((id (hunchentoot:post-parameter "id")) (current-state (story-get-state 'task id)) @@ -192,15 +191,11 @@ (setf (hunchentoot:session-value :username) nil)) (redirect 'login-page)) -(defun json-to-string (obj) - (with-output-to-string (out) - (encode-json obj out))) - (defun verify-credentials (audience assertion) (let ((response (http-request "https://verifier.login.persona.org/verify" :method :post :content-type "application/json" - :content (json-to-string + :content (encode-json-to-string `(("assertion" . ,assertion) ("audience" . ,audience))) :want-stream t))) @@ -218,8 +213,7 @@ (redirect 'main)) 403))) -(define-route scrumli-story ("stories/:id") +(define-route scrumli-story ("stories/:id" :content-type "json") (if (logged-in-p) - (with-output-to-string (out) - (encode-json (get-story id) out)) + (encode-json-to-string (get-story id)) 403)) -- cgit v1.2.3-54-g00ecf