diff options
-rw-r--r-- | lazybones.asd | 3 | ||||
-rw-r--r-- | lazybones.lisp | 11 | ||||
-rw-r--r-- | package.lisp | 5 |
3 files changed, 7 insertions, 12 deletions
diff --git a/lazybones.asd b/lazybones.asd index fb68736..d792750 100644 --- a/lazybones.asd +++ b/lazybones.asd @@ -8,4 +8,5 @@ :serial t :depends-on (#:clack #:jonathan #:alexandria #:split-sequence) :components ((:file "package") - (:file "lazybones"))) + (:file "lazybones") + (:file "decoders"))) diff --git a/lazybones.lisp b/lazybones.lisp index 9bd3014..e762f03 100644 --- a/lazybones.lisp +++ b/lazybones.lisp @@ -43,19 +43,8 @@ definition." (push (cons mimetype decoder) *decoders*))) -(defun read-body-to-string (stream content-length) - "Reads CONTENT-LENGTH characters from STREAM and returns a string." - (let ((string (make-string content-length))) - (read-sequence string stream) - string)) -(defun decode-json-body (stream len) - "Reads LEN characters from stream and decodes them as JSON, returning a PLIST" - (jonathan:parse (read-body-to-string stream len))) - -(add-decoder "application/json" #'decode-json-body) - (defun decode-body (stream content-type content-length) "Decodes the body according to the Content-Type header. diff --git a/package.lisp b/package.lisp index b46a3d6..4a15d03 100644 --- a/package.lisp +++ b/package.lisp @@ -22,3 +22,8 @@ #:start #:stop )) + +(defpackage #:lazybones.decoders + (:use #:cl) + (:import-from #:lazybones + #:add-decoder)) |