Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Luminus template +cljs produces bug in routes.home namespace #522

Open
cindywu opened this issue Jan 18, 2021 · 1 comment
Open

Luminus template +cljs produces bug in routes.home namespace #522

cindywu opened this issue Jan 18, 2021 · 1 comment

Comments

@cindywu
Copy link

cindywu commented Jan 18, 2021

Creating a new luminus project using lein new luminus new-project +cljs produces a bug in the new-project.routes.home namespace.

When the user runs lein run they will get this error:

Exception in thread "main" java.lang.ExceptionInInitializerError
	at clojure.main.<clinit>(main.java:20)
Caused by: java.lang.RuntimeException: Unable to resolve symbol: ok in this context, compiling:(new_proj/routes/home.clj:12:19)

To resolve the error, go into new-project.routes.home and make the following change:

(defroutes home-routes
  (GET "/" [] (home-page))
  (GET "/docs" [] (ok (-> "docs/docs.md" io/resource slurp))))

Change ok to response/ok.

I am pretty new to Clojure(Script), but if someone points me in the right direction I can try and fix and submit a PR.

@cindywu cindywu changed the title Luminus template +cljs produces bug in routes.home Luminus template +cljs produces bug in routes.home namespace Jan 18, 2021
@yogthos
Copy link
Member

yogthos commented Jan 18, 2021

It looks like you might have an older version of the template. Might be worth checking if you have a specific version pinned in your ~/.lein/profiles.clj, and you could clear the local maven cache for the template by removing the ~/.m2/repository/luminus/lein-template/ folder.

The latest version of the template should be generating the following content for new-project.routes.home:

(ns new-project.routes.home
  (:require
   [new-project.layout :as layout]
   [clojure.java.io :as io]
   [new-project.middleware :as middleware]
   [ring.util.response]
   [ring.util.http-response :as response]))

(defn home-page [request]
  (layout/render request "home.html"))

(defn home-routes []
  [""
   {:middleware [middleware/wrap-csrf
                 middleware/wrap-formats]}
   ["/" {:get home-page}]
   ["/docs" {:get (fn [_]
                    (-> (response/ok (-> "docs/docs.md" io/resource slurp))
                        (response/header "Content-Type" "text/plain; charset=utf-8")))}]])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants