mirror of
https://github.com/metosin/reitit.git
synced 2025-12-17 08:21:11 +00:00
Use status 301 and 308
This commit is contained in:
parent
875934360e
commit
820e13cffb
1 changed files with 2 additions and 1 deletions
|
|
@ -123,9 +123,10 @@
|
||||||
[{:keys [method] :or {method :both}}]
|
[{:keys [method] :or {method :both}}]
|
||||||
(let [redirect-handler (fn redirect-handler [request]
|
(let [redirect-handler (fn redirect-handler [request]
|
||||||
(let [uri (:uri request)
|
(let [uri (:uri request)
|
||||||
|
status (if (= (:method request) :get) 301 308)
|
||||||
maybe-redirect (fn maybe-redirect [path]
|
maybe-redirect (fn maybe-redirect [path]
|
||||||
(if (r/match-by-path (::r/router request) path)
|
(if (r/match-by-path (::r/router request) path)
|
||||||
{:status 308 ; permanent redirect
|
{:status status
|
||||||
:headers {"Location" path}
|
:headers {"Location" path}
|
||||||
:body ""}))]
|
:body ""}))]
|
||||||
(if (str/ends-with? uri "/")
|
(if (str/ends-with? uri "/")
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue