Function call in luminus not returning vector

I have a function called collatz that returns a vector with numbers. when calling collatz in luminus it returns the function not the vector. as a comparison I am calling also a vector and that works. why?

home.clj:

(defn collatz [x]
  [ ""
     {:middleware [middleware/wrap-csrf
                 middleware/wrap-formats]}
   ["/collatz" {:get
    (fn [request] 
      (layout/render request "collatz.html" {:c1 (collatz x) :c2 [1 2 3 4] :docs (-> "docs/collatz.md" io/resource slurp)}))}]])

collatz.html:

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>request vars</title>
    </head>
    <body>
      <h4>c1...</h4>
      <h4>{{c1}}</h4>
      {% for n in c1 %}
      <li>{{n}}</li>
      {% endfor %}
      <h4>c2: {{c2}}</h4>
    </body>
</html>

handler.html:

(ns ksite.handler
  (:require
    [ksite.middleware :as middleware]
    [ksite.layout :refer [error-page]]
    [ksite.routes.home :refer [home-routes ar dval t1 t2 variab collatz]]
    [reitit.ring :as ring]
    [ring.middleware.content-type :refer [wrap-content-type]]
    [ring.middleware.webjars :refer [wrap-webjars]]
    [ksite.env :refer [defaults]]
    [mount.core :as mount]))

(mount/defstate init-app
  :start ((or (:init defaults) (fn [])))
  :stop  ((or (:stop defaults) (fn []))))

(mount/defstate app-routes
  :start
  (ring/ring-handler
    (ring/router
      [(home-routes) (ar) (dval) (t1) (t2) (variab) (collatz 13)])
    (ring/routes
      (ring/create-resource-handler
        {:path "/"})
      (wrap-content-type
        (wrap-webjars (constantly nil)))
      (ring/create-default-handler
        {:not-found
         (constantly (error-page {:status 404, :title "404 - Page not found"}))
         :method-not-allowed
         (constantly (error-page {:status 405, :title "405 - Not allowed"}))
         :not-acceptable
         (constantly (error-page {:status 406, :title "406 - Not acceptable"}))}))))

(defn app []
  (middleware/wrap-base #'app-routes))

so I found the solution, remove the argument in the handler file:

  (ring/router
      [(home-routes) (ar) (dval) (t1) (t2) (variab) (collatz 13)])
  (ring/router
      [(home-routes) (ar) (dval) (t1) (t2) (variab) (collatz)])

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.