Fork me on GitHub

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


What are some (major?) differences between 0.53 and 0.5 ?


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)