你需要用不同的中間件定義分開包裝你的路由。下面是使用用於路由定義的Compojure一個例子:
(defroutes interactive-routes*
; Put your interactive routes here
; ...
)
(defroutes oauth-routes*
; Put your oauth routes here
; ...
)
(def interactive-routes
(-> #'interactive-routes*
(friend/authenticate {:credential-fn (partial creds/bcrypt-credential-fn users)
:workflows [(workflows/interactive-form)]})
))
(def oauth-routes
(-> #'oauth-routes*
(friend/authenticate {:credential-fn (partial creds/bcrypt-credential-fn users)
:workflows [(oauth2/workflow)]})
))
(defroutes all-routes
(ANY "*" [] interactive-routes)
(ANY "*" [] oauth-routes)
; Then do what you normally would with `all-routes` (e.g., wrap with more middleware, pass to ring server)
(感謝this answer用於在不同中間件不同的路由的音符)