This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2015-12-28
Channels
- # admin-announcements (72)
- # aws (23)
- # beginners (43)
- # boot (140)
- # cider (11)
- # cljs-dev (4)
- # cljsrn (82)
- # clojars (2)
- # clojure (215)
- # clojure-nl (2)
- # clojure-russia (149)
- # clojurecup (4)
- # clojurescript (159)
- # cursive (19)
- # datomic (47)
- # editors (1)
- # emacs (27)
- # hoplon (32)
- # jobs (11)
- # ldnclj (3)
- # mount (33)
- # off-topic (1)
- # om (380)
- # onyx (1)
- # re-frame (2)
- # reagent (54)
- # yada (63)
I should have posted a link : http://stackoverflow.com/questions/33805901/clojure-use-a-core-async-channel-with-yada-aleph
"No implementation of method: :to-body of protocol: #'yada.body/MessageBody found for class: manifold.stream.async.CoreAsyncSource" ;; :via ;; [{:type clojure.lang.ExceptionInfo
Well in this case yes I get it. I have to use ->source, but I don't get why the second fails ?
(assoc :body (let [ch (chan)]
(go-loop []
(>! ch " ok ")
(<! (timeout 100))
(recur))
(s/->source ch)))))
@nha hey, I answered your StackOverflow!
suggest you raise issues on GH for now, then once yada is released we can start building a StackOverflow KB
I don't want to clutter up SO for future users with issues that were due to yada's relative current immaturity
but np
I've just pushed a commit
Let me release it for you
one sec
just running my tests...
signing...
deploying to clojars...
done - this version also supports CORS now - see phonebook example for how this is done - basically you add an access-control entry to the resource
I'm tending to prefer that resource models are complete and contain everything needed prior to handling requests
that way things are faster (when requests arrive) and easier to debug when developing (no surprises)
@nha let me know if that new release does what you need
@malcolmsparks: I will ! Thanks
today I will be working on @stijn's security (authn/authz)
go with [yada "1.1.0-20151228.110457-4"]
reason is, you protect yourself from surprises if I choose to release a new snapshot
clojars gives us 'immutable' versions, even for snapshots - it's a nice idea and helps during a alpha/beta phase not to have to keep changing the project.clj
yeah, you can always go with 1.1.0-SNAPSHOT but the trouble is Maven will avoid checking for a new update if you have a version that is less than a day old - so it won't guarentee you the newest anyway
anyway good luck !
> "One of the things I think would be great is if the order of the interceptors is: parse-parameters > authentication > get-properties > authorization. The thing is that in get-properties you often need stuff like the currently logged-in user to retrieve something from the database (like 'my posts' or something)" - @stijn
Just tried it, got a new error : clojure.lang.Compiler$CompilerException: clojure.lang.ArityException: Wrong number of args (2) passed to: core/yada, compiling:(ts.clj:9:3)
this is a really nice idea - because authentication should depend on the parameters (headers, cookies, etc.) but be independent of the resource itself
authorization needs to be determined in the context of the resource - is this user (e.g. bob) allowed to access THIS resource
so it fits really nicely
@nha there have been a few changes, but nothing major, send me any errors you're getting
Well it is just my first example that throws en exception :
(def get-stream
"a stream of timestamps of this particular machine"
(yada (fn [ctx]
(-> (:response ctx)
(assoc :status 202)
(assoc :body (s/periodically 1000 #(str (System/currentTimeMillis) " ")))))
{:representations [{:media-type "application/json"
:charset "UTF-8"}
{:media-type "application/edn"
:charset "UTF-8"}]}))
Maybe I should look at your new examples.what's the exception?
clojure.lang.Compiler$CompilerException: clojure.lang.ArityException: Wrong number of args (2) passed to: core/yada, compiling:(ts.clj:9:3)
clojure.lang.ArityException: Wrong number of args (2) passed to: core/yada
yada only takes one argument now
you need to rewrite to...
`clojure
(yada (yada/resource {:methods {:get (fn [ctx] (as before))} :produces [...]})
whoops, let me try that again
clojure
(yada (yada/resource {:methods {:get (fn [ctx] (as before))} :produces [...]})
have a look at the phonebook example, that's similar to what you're doing
basically the {:methods ... :produces ...} map is called the resource-model - we turn it into a resource with (yada/resource) that does nothing more than validate your map basically
then, if your map has passed that validation check you get a Resource you can give to the yada function - it's single arity now and I think the second argument just allowed confusion to slip in
this stuff is actually written up in the manual now: https://github.com/juxt/yada/blob/master/dev/resources/user-manual.md
latest yada release looks good: https://travis-ci.org/juxt/yada/builds/99080777
thanks to @dominicm for the travis stuff
@malcolmsparks: the change worked