src/middleware/core.lisp @ 15eabbd388ea
default tip
Add a restart for ports already in use
author |
Steve Losh <steve@stevelosh.com> |
date |
Tue, 14 Mar 2017 17:46:14 +0000 |
parents |
ca726222b6f1 |
children |
(none) |
(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 &body body)
"Define a middleware at the symbol `name` to handle `op`.
As the body is executing `message-binding` will be bound to the message map.
"
(with-gensyms (fallback)
`(defun ,name (,fallback)
(lambda (,message-binding)
(handle-op ,message-binding ,op ,fallback
,@body)))))