1

次のように、アプリケーションでルートを設定しようとしています。

  • /:locale/ -> ホーム、ロケール バインディングあり
  • /:locale/search -> 検索、ロケール バインディングあり

これまでのところ、私のルーティングコードは次のとおりです。

(defn controller-routes [locale]
  (home/c-routes locale)
  (search/c-routes locale)))


(defroutes app-routes
  (route/resources "/")
  (context "/:locale" [locale]
    (controller-routes locale))
  no-locale-route
  (route/not-found "Not Found"))

検索/c ルート:

(defn c-routes [locale]
 (GET "/search" [] (index locale)))

ホーム/C ルート:

(defn c-routes [locale]
   (GET "/" [] (index locale)))

なぜこれがうまくいかないのか理解できませんが、現在 "/uk/search/" は正しく一致しますが、"/uk/" は 404 ページを返します。

どんな助けでも大歓迎です。ありがとう。

4

1 に答える 1

4

controller-routes現在のところ、最後のルート、つまり検索を返す通常の機能であるため、検索のみが機能します。必要なのは、c ルートもcontroller-routes使用して変更するルートを作成することです。defroutes

検索/c ルート:

(def c-routes (GET "/search" [locale] (index locale)))

ホーム/C ルート:

(def c-routes (GET "/" [locale] (index locale)))

上記のルートを使用する場所:

(defroutes controller-routes
  home/c-routes
  search/c-routes)


(defroutes app-routes
  (route/resources "/")
  (context "/:locale" [locale]
    controller-routes)
  no-locale-route
  (route/not-found "Not Found"))
于 2013-03-17T16:57:00.553 に答える