From e6b5011763c7f59ae8acf2c38d568c88ebd65ec1 Mon Sep 17 00:00:00 2001 From: Thomas Albers Raviola Date: Fri, 18 Oct 2024 19:34:44 +0200 Subject: Add test suit --- src/routes.lisp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src/routes.lisp') diff --git a/src/routes.lisp b/src/routes.lisp index 272d579..0de0307 100644 --- a/src/routes.lisp +++ b/src/routes.lisp @@ -1,14 +1,14 @@ -(in-package #:routes) +(in-package #:scgi-routes) ;; Source: https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods ;; Note: Not all http methods are yet implemented ;; Missing: :head :put :delete :connect :options :trace :patch -(defparameter *http-methods* - '(:get :post)) +(define-constant +http-methods+ + '(:get :post) :test 'equal) (deftype http-method () - `(member ,@*http-methods*)) + `(member ,@+http-methods+)) (defun route-method-p (object) (or (typep object 'http-method) @@ -239,11 +239,12 @@ route. If no route matches, then ERROR-HANDLER is called." (let* ((method (assoc-value headers :request-uri)) (uri (assoc-value headers :request-uri)) (query-bindings (quri:uri-query-params uri)) - (route (uri-route uri))) + (route (uri-route uri)) + (fragment (quri:uri-fragment uri))) (multiple-value-bind (entry path-bindings) (find-route route method *routes-table*) (if entry - (funcall (first entry) headers path-bindings query-bindings + (funcall (route-name entry) headers path-bindings query-bindings fragment) (funcall error-handler headers))))) (t (e) -- cgit v1.2.3