src/middleware/core.lisp @ d74fc3dab8fa

Add load-file and macroexpand middlewares
author Steve Losh <steve@stevelosh.com>
date Wed, 09 Dec 2015 17:47:41 +0000
parents dcaf8468adb1
children 3e9db801d234
(in-package #:nrepl)

(defvar *middleware* (fset:empty-map))


(defmacro handle-op (message op fallback &rest body)
  `(if (equal ,op (fset:lookup ,message "op"))
     (progn ,@body)
     (funcall ,fallback ,message)))

(defmacro define-middleware (name op message-binding &rest body)
  (let ((fallback (gensym)))
  `(defun ,name (,fallback)
     (lambda (,message-binding)
       (handle-op ,message-binding ,op ,fallback
                  ,@body)))))