Skip to content

Support for create-regex-dispatcher with groups #242

@HighriseHub

Description

@HighriseHub

Can we have support for such a function which supports regex dispatcher which supports groups

(defun create-regex-dispatcher-with-groups (regex handler)
  (let ((scanner (cl-ppcre:create-scanner regex)))
    (lambda (request)
      (multiple-value-bind (matchedp groups)
          (cl-ppcre:scan-to-strings scanner (hunchentoot:script-name request))
        (when matchedp
          (apply handler request (map 'list #'identity groups)))))))

I would like to define a regex like this

(push
 (create-regex-dispatcher-with-groups
  "^/hhub/nstcustomeraddress/([0-9]{10})$"
  'hhub-get-address-by-phone)
 hunchentoot:*dispatch-table*)

the function should have support for multiple arguments like phone here.

(defun hhub-get-address-by-phone (request phone)
  (declare (ignore request))
  (format t "Phone number: ~A~%" phone))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions