From 4e2d9a3a85f281c45f7036ae62430bf0cc909a11 Mon Sep 17 00:00:00 2001 From: Colin Okay Date: Wed, 16 Feb 2022 17:34:41 -0600 Subject: allowing get endpoints to respond to head requests --- lazybones.lisp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'lazybones.lisp') diff --git a/lazybones.lisp b/lazybones.lisp index c7be8d8..66192a2 100644 --- a/lazybones.lisp +++ b/lazybones.lisp @@ -195,6 +195,10 @@ list of values, in the case of success, or NIL in the case of failure." (request-method request) (request-routekey request))) +(defun method-match-for-dispatch-p (req-method ep-method) + "Either the arguments compare EQ or the first is :HEAD and the second is :GET." + (or (eq req-method ep-method) + (and (eq :head req-method) (eq :get ep-method)))) (defun find-endpoint-matching-key (app method key) "Returns a list. NIL represents failure to find match. @@ -203,7 +207,7 @@ Otherwise the result is (ENDPOINT . ARGS) where ENDPOINT is an endpoint instanceq and ARGS is a list of arguments to pass to ENDPOINT's handler function." (loop for endpoint in (app-endpoints app) - for match = (and (eql method (endpoint-method endpoint)) + for match = (and (method-match-for-dispatch-p method (endpoint-method endpoint)) (matches-routekey-p (endpoint-dispatch-pattern endpoint) key)) when match return (cons endpoint (when (listp match) match)))) -- cgit v1.2.3