liberator

ordnungswidrig 2015-08-31T12:07:56.000004Z

I’m proposing some clean up to liberator’s decision tree. Happy to see comments on this: https://github.com/clojure-liberator/liberator/pull/229

2015-08-31T12:33:41.000006Z

I found this discussion here: https://groups.google.com/forum/#!topic/clojure-liberator/P3Vc9sW1h7Q I had a similar request ("Assuming data is well formed and content negotiation finished ok, I would like to check if posted data makes sense in my application context."), but I'm not satisfied in doing it in "malformed?". It feels like there should be another node somewhere around "exists?", maybe "valid?" plus a ":handle-valid", where you can check the actual posted data and return a 400 with a description which business rules were violated. What do you think?

ordnungswidrig 2015-08-31T12:34:33.000007Z

For that use case there is processable-entity? which returns 422 on false.

ordnungswidrig 2015-08-31T12:34:47.000008Z

It’s not in the HTTP standard but from WEBDAV but’s it’s well known

ordnungswidrig 2015-08-31T12:35:32.000009Z

400 should be returned if the request is syntactically invalid. e.g. a broken JSON document

ordnungswidrig 2015-08-31T12:36:19.000010Z

422 is when the server understands the request but wants to refuse the request entity („body“).

ordnungswidrig 2015-08-31T12:36:33.000011Z

i.e. syntactic vs. semantic validity

2015-08-31T12:36:36.000012Z

True, that makes sense. Thanks for the quick reply :simple_smile:

ordnungswidrig 2015-08-31T13:01:17.000013Z

Great, tell me when you need help.

ska 2015-08-31T13:02:28.000014Z

@ordnungswidrig: thanks for helping us out quickly :simple_smile:

ordnungswidrig 2015-08-31T13:23:25.000015Z

you’re welcome :simple_smile:

2015-08-31T13:25:48.000016Z

@ordnungswidrig: new graph looks a lot less complicated... what is meant by the grey nodes though? Is the idea that the user can't override those ones anymore?

2015-08-31T13:25:49.000017Z

Yeah, thanks a lot - and no help needed, it was super easy to add the handler to :processable?, even although I'm using liberator through sweet-liberty :simple_smile:

ordnungswidrig 2015-08-31T13:58:56.000018Z

@rickmoynihan: you can override those, but it does not make sense except for „side-effects“. They test the request method for a particular verb and there now way to the outcome could be different.

2015-08-31T14:02:08.000020Z

a legend would be useful

2015-08-31T14:02:53.000021Z

but yes that makes sense

ordnungswidrig 2015-08-31T19:59:02.000022Z

Oh, a legend is a good idea. I’m afraid this will confuse the graphviz layout algorithm once again :simple_smile:

ordnungswidrig 2015-08-31T19:59:14.000023Z

@rickmoynihan: do you mind raising an issue for it?

2015-08-31T22:49:13.000024Z

well I guess the legend could be in the accompanying text not in the graph-viz svg