Update README

This commit is contained in:
paku 2024-02-14 01:09:42 +09:00
parent 3382169913
commit 5ed1cb6b51
2 changed files with 75 additions and 3 deletions

View file

@ -1,6 +1,6 @@
MIT License MIT License
Copyright (c) 2024 paku Copyright (c) 2024 skyizwhite
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal

View file

@ -1,2 +1,74 @@
# ningle-fbr # ningle-fbr (WIP)
Plugin for ningle to enable file-based routing Plugin for [ningle](https://github.com/fukamachi/ningle) and [jingle](https://github.com/dnaeon/cl-jingle) to enable file-based routing
# Usage
To use ningle-fbr, you must use [package-inferred-system](https://asdf.common-lisp.dev/asdf/The-package_002dinferred_002dsystem-extension.html).
`/example.asd`
```lisp
(defsystem "example"
:class :package-inferred-system
:pathname "src"
:depends-on ("example/app")
```
`/src/app.lisp`
```lisp
(uiop:define-package #:example
(:nicknames #:example/app)
(:use #:cl)
(:import-from #:ningle)
(:import-from #:ningle-fbr))
(in-package #:example/app)
(defparameter *app* (make-instance 'ningle:<app>))
(defun update-routes ()
(ningle-fbr:enable-file-based-routing
*app*
:dir "src/routes"
:system "example"
:system-pathname "src"))
(update-routes)
```
## Static routing
`/src/routes/index.lisp``/`
```lisp
(uiop:define-package #:example/routes/index
(:use #:cl)
(:export #:on-get
#:on-post
#:on-put
#:on-delete))
(in-package #:example/routes/index)
(defun on-get (params)
...)
(defun on-post (params)
...)
(defun on-put (params)
...)
(defun on-delete (params)
...)
```
## Dynamic routing
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.
`/src/routes/user/=name.lisp``/user/:name`
# License
Licensed under MIT License. 
Copyright (c) 2024, skyizwhite.