Fork me on GitHub
#ring-swagger
<
2018-12-06
>
Jon Walch20:12:09

Hello, I’m using compojure-api version “2.0.0-alpha28”, trying to set up an async handler.

(context "/test" []
      :tags ["Testing"]
      (GET "/" []
        :summary "testing"
        (async/go
          (async/<! (async/timeout 500))
          (ok {:message "Hello"}))))
When i try to hit the endpoint, I get:
ERROR compojure.api.exception: No implementation of method: :render of protocol: #'compojure.response/Renderable found for class: clojure.core.async.impl.channels.ManyToManyChannel
I’ve noticed that in https://github.com/metosin/compojure-api/tree/master/examples/async the project.clj contains
:ring {:handler example.handler/app
         :async? true}
but from what I understand, that’s only relevant when running with lein, which I’m not doing. Any thoughts?

ikitommi20:12:24

@jon324 hi. the async requires the server to be run in ring-async mode: the server should call the application with 3 arguments, described in here: https://www.booleanknot.com/blog/2016/07/15/asynchronous-ring.html

ikitommi20:12:42

Jetty support ring-async oob, with Aleph, Immutant or http-kit, you need to write 1+ lines of boilerplate to do this.

Jon Walch21:12:30

Are there any resources for the boilerplate for aleph?

Jon Walch22:12:48

I’m trying to see if I can do something similar with Jetty by following this blog post: https://www.lucagrulla.com/posts/server-sent-events-with-ring-and-compojure/ On this line (fn [req res raise] I get

ERROR compojure.api.exception: Wrong number of args (1) passed to: services/fn--41918/fn--41919
clojure.lang.ArityException: Wrong number of args (1) passed to: services/fn--41918/fn--41919
        at clojure.lang.AFn.throwArity(AFn.java:429)
        at clojure.lang.AFn.invoke(AFn.java:32)
        at compojure.response$eval18314$fn__18315.invoke(response.clj:47)
        at compojure.response$eval18236$fn__18237$G__18227__18244.invoke(response.clj:7)
        at compojure.core$wrap_response$fn__20191.invoke(core.clj:158)
        at compojure.core$wrap_route_middleware$fn__20175.invoke(core.clj:128)
        at compojure.core$wrap_route_info$fn__20180.invoke(core.clj:137)
        at compojure.core$wrap_route_matches$fn__20184.invoke(core.clj:146)
        at compojure.api.routes.Route.invoke(routes.clj:90)
        at compojure.core$routing$fn__20199.invoke(core.clj:185)

nigel03:09:24

@jon324 I’m running into the same issue, did you ever get this figured out?

Jon Walch22:12:18

Any ideas why I’m having trouble with the arity 3 call?