diff options
author | Thomas Albers Raviola <thomas@thomaslabs.org> | 2024-10-18 19:34:44 +0200 |
---|---|---|
committer | Thomas Albers Raviola <thomas@thomaslabs.org> | 2024-10-18 19:34:44 +0200 |
commit | e6b5011763c7f59ae8acf2c38d568c88ebd65ec1 (patch) | |
tree | b0717a2af8366fe6849a4a7f28170d8f61bd9242 /src | |
parent | 1be9ab5f5a929153b4a8193f6c12bab45fd00ab2 (diff) |
Add test suit
Diffstat (limited to 'src')
-rw-r--r-- | src/package.lisp | 3 | ||||
-rw-r--r-- | src/routes.lisp | 13 |
2 files changed, 9 insertions, 7 deletions
diff --git a/src/package.lisp b/src/package.lisp index c2ea5b2..016f438 100644 --- a/src/package.lisp +++ b/src/package.lisp @@ -1,4 +1,5 @@ -(defpackage #:routes +(defpackage #:scgi-routes + (:nicknames #:routes) (:use #:cl #:alexandria #:split-sequence) 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) |