This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-03-08
Channels
- # admin-announcements (3)
- # alda (2)
- # beginners (66)
- # boot (54)
- # cider (21)
- # clara (1)
- # cljsfiddle (32)
- # cljsrn (9)
- # clojars (4)
- # clojure (164)
- # clojure-dusseldorf (4)
- # clojure-japan (2)
- # clojure-norway (1)
- # clojure-russia (76)
- # clojure-sg (8)
- # clojurescript (19)
- # core-async (1)
- # core-typed (1)
- # cursive (6)
- # datomic (1)
- # editors (48)
- # hoplon (20)
- # immutant (2)
- # jobs-discuss (6)
- # ldnclj (1)
- # om (82)
- # onyx (6)
- # parinfer (11)
- # proton (2)
- # re-frame (113)
- # reagent (17)
- # testing (11)
- # untangled (11)
- # vim (4)
- # yada (38)
Hi yada guys! unfortunately struggling again trying to extend-protocl PutResult so it returns data/body besides 204 status code this is my simple approach to do that
(defrecord MyRecordType [d])
(extend-protocol PutResult
MyRecordType
(interpret-put-result [o ctx]
(assoc-in ctx [:response :body] (:d o))))
when i try this code after getting nil as response my cider or aleph freezes 😐
any ideas ??
using [yada "1.1.0-20160304.082603-32"]
@tangrammer: can you tell if your interpret-put-result is called? is there some logging you can add?
Hi Malcolm! good to have you over here yep, I get proper logging calls I was wondering, that maybe I'm having dependency conflicts
@malcolmsparks: (or any other masters of yada) I have a new stack trace to divine
java.lang.IllegalArgumentException: cannot treat nil as HTTP response for request to "
at aleph.http.server$invalid_value_response.invokeStatic(server.clj:132)
at aleph.http.server$invalid_value_response.invoke(server.clj:129)
at aleph.http.server$handle_request$fn__24215$fn__24216.invoke(server.clj:185)
at manifold.deferred$fn__15596$chain_SINGLEQUOTE____15617.invoke(deferred.clj:750)
at manifold.deferred$fn__15596$subscribe__15597$fn__15602.invoke(deferred.clj:716)
at manifold.deferred.Listener.onSuccess(deferred.clj:219)
at manifold.deferred.Deferred$fn__15450.invoke(deferred.clj:396)
at manifold.deferred.Deferred.success(deferred.clj:396)
at manifold.deferred$success_BANG_.invokeStatic(deferred.clj:243)
at manifold.deferred$success_BANG_.invoke(deferred.clj:240)
at manifold.deferred$catch_SINGLEQUOTE_$fn__15680.invoke(deferred.clj:959)
at manifold.deferred.Listener.onSuccess(deferred.clj:219)
at manifold.deferred.Deferred$fn__15450.invoke(deferred.clj:396)
at manifold.deferred.Deferred.success(deferred.clj:396)
at manifold.deferred$success_BANG_.invokeStatic(deferred.clj:243)
at manifold.deferred$success_BANG_.invoke(deferred.clj:240)
at manifold.deferred$fn__15596$chain_SINGLEQUOTE____15617.invoke(deferred.clj:737)
at manifold.deferred$fn__15596$subscribe__15597$fn__15598.invoke(deferred.clj:710)
at manifold.deferred.Listener.onSuccess(deferred.clj:219)
at manifold.deferred.Deferred$fn__15450.invoke(deferred.clj:396)
at manifold.deferred.Deferred.success(deferred.clj:396)
at manifold.deferred$success_BANG_.invokeStatic(deferred.clj:243)
at manifold.deferred$success_BANG_.invoke(deferred.clj:240)
at aleph.http.server$handle_request$fn__24200$f__15079__auto____24201.invoke(server.clj:153)
at clojure.lang.AFn.run(AFn.java:22)
at io.aleph.dirigiste.Executor$Worker$1.run(Executor.java:62)
at manifold.executor$thread_factory$reify__14971$f__14972.invoke(executor.clj:36)
at clojure.lang.AFn.run(AFn.java:22)
at java.lang.Thread.run(Thread.java:745)
I have tests that test the route being hit from the routing down the stack, but not hitting the http server… So I think it’s between the two.
here are the related components
(defn create-vhosts-model [api host scheme ]
(vhosts-model
[{:scheme (keyword scheme) :host host}
(:routes api)
[true (yada nil)]]))
(defrecord ServerComponent [api port host scheme ]
Lifecycle
(start [component]
(timbre/info "Starting server on " host port )
(let [model (create-vhosts-model api host scheme )]
(assoc component
:vhosts-model model
:server (http/start-server (make-handler model) {:port (read-string port) :raw-stream? true}))))
@ericfode: that stack trace is when there are no bidi matches
My guess is that the host isn't matching
can't help more without the api itself
are you using bidi method guards? (you shouldn't need to with yada)
but everything looks ok to me
(defn api [db]
["/" {"services" {"" (-> (new-service-index-resource db)
(assoc :id ::service-index))
["/" :entry] (-> (new-service-resource db)
(assoc :id ::service))}}])
what's you host?
you must include the port number in the host too
e.g. localhost:8080
could that explain it?
that is really non-obvious
So I was having trouble with that when i deployed it to Cloud Foundry (think heroku), which proxies everything and ends up with no port
that's ok, that's the purpose of host - to cope with reverse proxies
but then localhost wouldn't match - the host has to be what's in the URI
that's why you can add multiple host sections in a vector
so if your site is working in dev in localhost:8080 but you deploy to http://example.org, then you must have http://example.org in your vhost
the point of all this complexity it to allow you to forge URIs across vhosts - eventually you'll be able to import swagger definitions and forge URIs to remote services
sorry if you've been caught out by a feature-in-progress
I've always found the whole vhost thing to be a pain with developing APIs - you get everything working fine on localhost, then everything breaks when you deploy into prod, or add a reverse proxy, etc.
Is there somewhere I might be able to add some better logging to yada for that sort of thing? Or do you have something planned?
yada should have some request logging bulit-in, but doesn't yet - but yes, I have a console planned which will allow you to browse these logs (to debug, etc. )