lfe-mug / lrootes

Macros and functions for creating, combining, and composing routes for lmug apps
3 stars 0 forks source link

Put together a development plan #1

Open oubiwann opened 8 years ago

oubiwann commented 8 years ago

Need to evaluate/review:

Need to create:

oubiwann commented 8 years ago

Clojure REPL session from today:

(require '[clojure.walk :refer [macroexpand-all]])

(require '[compojure.core :refer [defroutes GET]]
         '[compojure.route :as route])

(defroutes app
  (GET "/" [] "<h1>Hello World</h1>")
  (route/not-found "<h1>Page not found</h1>"))

(macroexpand-all '(defroutes app
  (GET "/" [] "<h1>Hello World</h1>")
  (route/not-found "<h1>Page not found</h1>")))

(def app
  (compojure.core/routes
    (compojure.core/make-route
      :get #clout.core.CompiledRoute{:source "/", :re #"/", :keys [], :absolute? false}
           (fn* ([request__3003__auto__]
            (let* []
              (do "<h1>Hello World</h1>")))))
    (route/not-found "<h1>Page not found</h1>")))

(def req {})
(app req)
{:status 404
 :headers {"Content-Type" "text/html; charset=utf-8"}
 :body "<h1>Page not found</h1>"}

(def req {:uri "/" :request-method 
          :get :server-port 80 
          :server-name "localhost" 
          :remote-addr "10.0.4.64" 
          :scheme "http"})
(app req) ; gives 200
{:status 200
 :headers {"Content-Type" "text/html; charset=utf-8"}
 :body "<h1>Hello World</h1>"}