From 438030b0b89dc706c37932616e6bf82d0416ea26 Mon Sep 17 00:00:00 2001 From: paku Date: Thu, 11 Apr 2024 23:34:28 +0900 Subject: [PATCH] Fix --- README.md | 24 ++++++++++++++---------- src/main.lisp | 4 ++-- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 6bd6f07..09f5183 100644 --- a/README.md +++ b/README.md @@ -24,23 +24,27 @@ To use ningle-fbr, you must use [package-inferred-system](https://asdf.common-li (:nicknames #:example/app) (:use #:cl) (:import-from #:ningle) - (:import-from #:ningle-fbr)) + (:import-from #:ningle-fbr +          #:assign-routes)) (in-package #:example/app) (defparameter *app* (make-instance 'ningle:)) -(defun update-routes () - (ningle-fbr:enable-file-based-routing - *app* - :directory "src/routes" - :system "example")) - -(update-routes) +(assign-routes *app* + :directory "src/routes" + :system "example") ``` ## Static routing `/src/routes/index.lisp` → `/` + +`/src/routes/hello.lisp` → `/hello` + +`/src/routes/users/index.lisp` → `/users` + +`/src/routes/nested/page.lisp` → `/nested/page` + ```lisp (uiop:define-package #:example/routes/index (:use #:cl) @@ -67,9 +71,9 @@ To use ningle-fbr, you must use [package-inferred-system](https://asdf.common-li A file or directory name prefixed with '=' indicates a dynamic path. -In the example below, the name parameter can be obtained from handler's params. +In the example below, the parameter `id` can be obtained from handler's params. -`/src/routes/user/=name.lisp` → `/user/:name` +`/src/routes/user/=id.lisp` → `/user/:id` # License diff --git a/src/main.lisp b/src/main.lisp index bea9efe..13f79c9 100644 --- a/src/main.lisp +++ b/src/main.lisp @@ -3,7 +3,7 @@ (:use #:cl) (:local-nicknames (#:re #:cl-ppcre)) (:local-nicknames (#:ng #:ningle)) - (:export #:enable-file-based-routing)) + (:export #:assign-routes)) (in-package :ningle-fbr) (defun remove-file-type (namestr) @@ -52,7 +52,7 @@ (defparameter *http-request-methods* '(:GET :POST :PUT :DELETE :HEAD :CONNECT :OPTIONS :PATCH)) -(defun enable-file-based-routing (app &key directory system) +(defun assign-routes (app &key directory system) (loop :for (url . pkg) :in (dir->urls-and-packages directory system) :do (ql:quickload pkg)