aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCoin Okay <cbeok@protonmail.com>2020-04-22 20:33:42 -0500
committerCoin Okay <cbeok@protonmail.com>2020-04-22 20:33:42 -0500
commit85b00ffcca2590d737309da0d71f7f5061aff12d (patch)
treed395eb1dc7902f2eb065d71151e514c6b251fb1b
parent1fe086af924e7c497586d41bfae203f097bf6f81 (diff)
created decoders package, moved json decoder
-rw-r--r--lazybones.asd3
-rw-r--r--lazybones.lisp11
-rw-r--r--package.lisp5
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))