How to redirect get methods with Liberator in Clojure? -


i have endpoint called /account provides user info(returns html).

when unauthorised user tries access endpoint need able redirect login page in liberator found post-redirect far , post methods.

i need redirect get methods well, how can achieve this?

i found workaround following code trick:

(defn account   []   (resource :allowed-methods [:get]              :available-media-types ["text/html"]              :exists? (fn [_] false)              :existed? (fn [_] true)              :moved-temporarily? (fn [ctx] {:location "/redirected-path-or-url"})              :handle-ok (fn [ctx]                          [:html ...])              :handle-exception (fn [_]                                 "something went wrong"))) 

or can check :authorized? , return login html :handle-unauthorized doubt it's practice or not.


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -