aboutsummaryrefslogtreecommitdiff
path: root/src/protocol.lisp
diff options
context:
space:
mode:
Diffstat (limited to 'src/protocol.lisp')
-rw-r--r--src/protocol.lisp25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/protocol.lisp b/src/protocol.lisp
index 74019b1..6951077 100644
--- a/src/protocol.lisp
+++ b/src/protocol.lisp
@@ -112,6 +112,31 @@ on the size of request bodies.")
(check-request-compliance (find-class epclass)))
(:method ((epclass t))))
+(defgeneric slot-value-mapper (endpoint-class initarg slot-value)
+ (:documentation "Values arrive from clients in all manner of ways: in a JSON body, in
+query arguments, as form body posts. Weekend allows users to register
+body parsers, which transform post bodies according to the request's
+mimetype. However, sometimes this isn't good enough.
+
+A value may require additional alteration before it fills an endpoint
+slot.
+
+SLOT-VALUE-MAPPER is specialized on endpoints, initarg names, and slot
+value types to parse or transform values to be what they out to be for
+a slot's declared type.
+
+ENDPOINT-CLASS values MUST BE AN ENDPOINT CLASS.
+INITARG values MUST BE A KEYWORD.")
+
+ (:method :around (endpoint (initarg t) value)
+ (assert (keywordp initarg) (initarg) "Initarg is not a keyword ~a"
+ initarg)
+ (call-next-method))
+
+ (:method (endpoint initarg value)
+ value))
+
+
(defgeneric authenticate (endpoint)
(:documentation "Returns a boolean. Any protected endpoint should implement
this. Called before handling, should be used to supply