These are chat archives for clojure-liberator/liberator

12th
Mar 2015
Hans Hübner
@hanshuebner
Mar 12 2015 07:32
Today is the day where i'll try to use liberator as the front end to the Datomic based thing that I've been working on :)
Hans Hübner
@hanshuebner
Mar 12 2015 08:28
The documentation states "While If-Modified-Since requires that the clocks of client and server are sufficiently in sync", which is not the case.
If-Modified-Since does not require the clocks of the client and the server to be in sync, but as it works only on 1 second granularity due to the time format used, it is not suitable for resources that change frequently and it can even fail with rarely changing resources if two updates happen in the same second and the client fetches the first version of that second.
Right there, the tutorial also says " A resource can generate an ETag by providing a function at the key :etag", but the example shows just some code snippet, not a function. What is the context in which that piece of code is evaluated? I will need to look at the request to determine the etag, so a contextless expression won't really do, I guess.
Hans Hübner
@hanshuebner
Mar 12 2015 08:34
I'm guessing that the argument to :etag is just a function of one argument, the context. The tutorial could be clearer about that.
Hans Hübner
@hanshuebner
Mar 12 2015 13:10
For my current application, liberator works very well, thanks!
Hans Hübner
@hanshuebner
Mar 12 2015 13:24
Here is a real question, though: We're using clj-time (maybe wrongly, as it hurts us everywhere), but the json serialization of liberator does not know how to deal with clj-time instances. Is there a way to make this work?
Hans Hübner
@hanshuebner
Mar 12 2015 13:30
Well, apparently, liberator also cannot deal with java.util.Time. This will be a roadblock for us
Hans Hübner
@hanshuebner
Mar 12 2015 14:18
I've seen clojure-liberator/liberator#71 - That'll do for me.
Philipp Meier
@ordnungswidrig
Mar 12 2015 19:48
@hanshuebner the simples way to plug in custom represenation generation for JSON is to provide a custom function at :as-responsewhich should accept the data returned by a handler and the context. You can check the media-type in (get-in ctx [:represenation :media-type]) and if it’s json call your json library of choice. For the other media types you can delegate to liberator.representation/as-response.
Hans Hübner
@hanshuebner
Mar 12 2015 20:02
Nice, thanks!