9d3d9514dbd8

Formatting
[view raw] [browse files]
author Steve Losh <steve@stevelosh.com>
date Sat, 09 Apr 2016 21:59:53 +0000
parents 7d0cd39ee703
children 051685b12e07
branches/tags (none)
files src/middleware/eval.lisp src/middleware/macroexpand.lisp src/middleware/session.lisp

Changes

--- a/src/middleware/eval.lisp	Sat Apr 09 21:45:42 2016 +0000
+++ b/src/middleware/eval.lisp	Sat Apr 09 21:59:53 2016 +0000
@@ -73,7 +73,7 @@
   "Evaluate each form in `forms` and shuttle back the responses.
 
   `forms` can be a string, in which case the forms will be read out of it, or
-  a ready-to-go list for actual forms.
+  a ready-to-go list of actual forms.
 
   Other middlewares (e.g. `load-file`) can use this function to evaluate things
   and send the results back to the user.
--- a/src/middleware/macroexpand.lisp	Sat Apr 09 21:45:42 2016 +0000
+++ b/src/middleware/macroexpand.lisp	Sat Apr 09 21:59:53 2016 +0000
@@ -1,6 +1,7 @@
 (in-package #:nrepl)
 
 (define-middleware wrap-macroexpand "macroexpand" message
+  ;; TODO: handle mangled input
   (let ((form (read-from-string (fset:lookup message "form"))))
     (respond message
              (make-map
--- a/src/middleware/session.lisp	Sat Apr 09 21:45:42 2016 +0000
+++ b/src/middleware/session.lisp	Sat Apr 09 21:59:53 2016 +0000
@@ -23,18 +23,21 @@
   (hash-keys *sessions*))
 
 
-(defun wrap-session (h)
+(defun wrap-session (handler)
   "Handle wrapping incoming messages in sessions.
 
-   If a message contains a session key, look up that session in the list of
-   registered sessions and bind it into *session*.
+  If a message contains a session key, look up that session in the list of
+  registered sessions and bind it into *session*.
 
-   If a message comes in without a session id, create a new session for it and
-   patch the session id into the message before continuing on down the
-   middleware stack.  Also binds the session into *session*.  Note that this
-   will NOT register the session into the main map of sessions.
+  If a message comes in without a session id, create a new session for it and
+  patch the session id into the message before continuing on down the
+  middleware stack.  Also binds the session into *session*.
 
-   "
+  Note that this implicit creation will NOT register the session into the main
+  map of sessions.  To register the session so it'll stick around the client
+  needs to do a `clone` op.
+
+  "
   (lambda (message)
     (let* ((session-id (fset:lookup message "session"))
            (session (if session-id
@@ -42,7 +45,7 @@
                       (create-session)))
            (session-id (or session-id (random-uuid)))
            (*session* session))
-      (funcall h (fset:with message "session" session-id)))))
+      (funcall handler (fset:with message "session" session-id)))))
 
 (define-middleware wrap-session-ls "ls-sessions" message
   (respond message