This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2015-07-15
Channels
- # admin-announcements (113)
- # announcements (6)
- # beginners (18)
- # boot (294)
- # bristol-clojurians (3)
- # cider (90)
- # clojure (122)
- # clojure-berlin (42)
- # clojure-czech (1)
- # clojure-dev (19)
- # clojure-italy (4)
- # clojure-japan (5)
- # clojure-korea (10)
- # clojure-russia (1)
- # clojure-uk (5)
- # clojured (1)
- # clojurescript (179)
- # datomic (2)
- # editors (10)
- # indycljs (1)
- # jobs (1)
- # ldnclj (29)
- # off-topic (33)
- # onyx (11)
- # reagent (48)
- # yada (18)
I've been working on yada a lot recently and the 0.5.x branch is nearing completion - just a few more tests to fix and work on the documentation, should be just a couple of weeks now
the most important difference is that yada 0.5 promotes state to being 'first class' - all yada resources are associated with some state (mutable or immutable) - for example (yada "Hello World") yields a Ring handler still, but the state is a string
yada then teases out all the possible properties of that state, so for the example above, we can't tell the content-type, we can know that a java string can be represented in a variety of charsets
it doesn't sound too much, but it's a profound change - you can use Files as state, or even whole directories, or other things like database tables, redis stores, and other things
in the (yada "Hello World") we can tell the last-modified time of the string (the time the yada function was called)
but we can also do (yada (atom "Hello World")) and yada adds a watch to detect changes that it can then report as the last-modified property
there are quite a few built-in types of state you can use, but you can add your own via defrecord - of course there is a single Resource protocol behind all this
A single function is also considered to be a valid state, so (yada (fn [ctx] {:status 415 :body "I'm a teapot"}))
will work too, where (:method ctx) is the method
Content negotiation is also greatly overhauled - you can specify possible representations at a vector of maps like this:
[{:method :get :content-type #{"text/html" "text/plain"} :charset #{"latin1" "utf-8"} :language #{"en-US" "fr-FR"}} {:method :post :content-type #{"application/json"}}]
So you can specify that you can serve a resource in the Chinese language in Shift_JIS encoding, and English in US-ASCII, but not vice-versa - and do this with method, content-type, charset, language, content-encoding and transfer-encoding - it's quite powerful
But generally speaking, new yada users should not notice this state abstraction going on, yada will (i hope) 'just work' and 'do the right thing' in the majority of cases
Everything still works with Swagger, and there is support for sync and async for almost every operation
0.5 also has a full comprehensive test suite
Also, all methods are now backed by a Method protocol, and you can define your own methods (if you must)