2024-12-23 06:58:14 +00:00
# trailing-slash middleware
This middleware handles Trailing Slash in the URL on a GET request.
2024-12-25 06:38:52 +00:00
`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.
2024-12-23 06:58:14 +00:00
## 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
2024-12-25 06:38:52 +00:00
#:append -trailing-slash))
2024-12-23 06:58:14 +00:00
(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
2024-12-25 06:38:52 +00:00
(append-trailing-slash)
2024-12-23 06:58:14 +00:00
*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
2024-12-25 06:38:52 +00:00
#:trim -trailing-slash))
2024-12-23 06:58:14 +00:00
(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
2024-12-25 06:38:52 +00:00
(trim-trailing-slash)
2024-12-23 06:58:14 +00:00
*raw-app* ))
```
## Note
It will be enabled when the request method is GET and the response status is `404` .