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
Post a Comment