改訂版
コメントでより良い書き方を教えていただいたのでそちらで書き直しました。
ring.util.response
ではなく、ataraxy.response
を利用してredirectをする方法です。
https://github.com/weavejester/ataraxy/blob/0.4.0/src/ataraxy/response.clj#L50-L66
(ns foo.root
(:require [ataraxy.response :as response]
[integrant.core :as ig]))
(defmethod ig/init-key ::index [_ options]
(fn [{[_] :ataraxy/result}]
[::response/found "/bar"]))
ここから以前の実装方法
サンプル
こんな感じです。
(ns foo.root
(:require [ataraxy.response :as response]
[integrant.core :as ig]
[ring.util.response :refer [redirect]]))
(defmethod ig/init-key ::index [_ options]
(fn [{[_] :ataraxy/result}]
(redirect "/bar")))
ちなみにredirectは↓みたいなMapを返す関数のようです。
{:status 302, :headers {"Location" "/bar"}, :body ""}
間違い
最初はうっかり↓みたいに書いて500エラーになりました。
;; ダメな例
(defmethod ig/init-key ::index [_ options]
(fn [{[_ q] :ataraxy/result}]
;; response/okは要らなかった
[::response/ok (redirect "/bar")]))