-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f0306d8
commit 579c08a
Showing
3 changed files
with
56 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,17 @@ | ||
# lack-mw | ||
|
||
Middleware collection for [Lack](https://github.com/fukamachi/lack). | ||
|
||
These middlewares were ported from [Hono](https://github.com/honojs/hono). | ||
|
||
## Middlewares | ||
|
||
- **trailing-slash** | ||
Handles trailing slashes in URLs for GET requests. | ||
If the requested resource isn’t found, it redirects to the correct URL accordingly. | ||
- `*append-trailing-slash*` | ||
Redirects to the URL **with** a trailing slash. | ||
- `*trim-trailing-slash*` | ||
Redirects to the URL **without** a trailing slash. | ||
- [trailing-slash](/docs/trailing-slash.md) | ||
- Coming soon... | ||
|
||
## License | ||
|
||
Licensed under the MIT License. | ||
|
||
© 2024 skyizwhite | ||
© 2024 - present, skyizwhite | ||
|
||
© 2021 - present, Yusuke Wada and Hono contributors |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# trailing-slash middleware | ||
|
||
This middleware handles Trailing Slash in the URL on a GET request. | ||
|
||
`*append-trailing-slash*` redirects the URL to which it added the Trailing Slash if the content was not found. Also, `*trim-trailing-slash*` will remove the Trailing Slash. | ||
|
||
## Usage | ||
|
||
Example of redirecting a GET request of `/about/me` to `/about/me/`. | ||
|
||
```lisp | ||
(defpackage #:app/main | ||
(:use #:cl) | ||
(:import-from #:ningle) | ||
(:import-from #:lack) | ||
(:import-from #:lack-mw | ||
#:*append-trailing-slash*)) | ||
(in-package #:app/main) | ||
(defparameter *raw-app* (make-instance 'ningle:app)) | ||
(setf (ningle:route *raw-app* "/about/me/") | ||
"With Trailing Slash") | ||
(defparameter *app* | ||
(lack:builder | ||
*append-trailing-slash* | ||
*raw-app*)) | ||
``` | ||
|
||
Example of redirecting a GET request of `/about/me/` to `/about/me`. | ||
|
||
```lisp | ||
(defpackage #:app/main | ||
(:use #:cl) | ||
(:import-from #:ningle) | ||
(:import-from #:lack) | ||
(:import-from #:lack-mw | ||
#:*trim-trailing-slash*)) | ||
(in-package #:app/main) | ||
(defparameter *raw-app* (make-instance 'ningle:app)) | ||
(setf (ningle:route *raw-app* "/about/me") | ||
"Without Trailing Slash") | ||
(defparameter *app* | ||
(lack:builder | ||
*trim-trailing-slash* | ||
*raw-app*)) | ||
``` | ||
|
||
## Note | ||
|
||
It will be enabled when the request method is GET and the response status is `404`. |