Understanding Ring and Appengine-magic handlers (Clojure)

I started working on some clojure web applications and decided to use the Ring + Compojure combination. I recently decided to try Google Appengine using AppEngine-magic (https://github.com/gcv/appengine-magic). However, both appengine-magic (via the start function) and the run-jetty function for calls accept only 1 handler as a parameter, I implement several handlers and would like to know how to deploy them.

Thanks in advance, Ze

+3
source share
2 answers

- , - , , , , . , , , ; , run-jetty ( ).

Ring + Compojure ( "" ) , URI (, 404), . defroutes, - .

- - , . "" URI nil, , ( , nil out, , , 404).

Compojure ; , Compojure.

+5

, , ring.middleware, :

(defn wrap-ohandler [f handler]
  (fn [req]
    (let [ res (f req) ]
      (if (= res nil) (handler req) res))))

(def handler-wrapped 
  (-> #'main-handler
    (wrap-ohandler #'anotherhandler )
    (wrap-stacktrace)
    (wrap-params)))

, ?

+1

Source: https://habr.com/ru/post/1780801/


All Articles