Fork me on GitHub
#liberator
<
2015-08-31
>
ordnungswidrig12:08:56

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

bernhard12:08:41

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?

ordnungswidrig12:08:33

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

ordnungswidrig12:08:47

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

ordnungswidrig12:08:32

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

ordnungswidrig12:08:19

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

ordnungswidrig12:08:33

i.e. syntactic vs. semantic validity

bernhard12:08:36

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

ordnungswidrig13:08:17

Great, tell me when you need help.

ska13:08:28

@ordnungswidrig: thanks for helping us out quickly simple_smile

ordnungswidrig13:08:25

you’re welcome simple_smile

rickmoynihan13:08:48

@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?

bernhard13:08:49

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

ordnungswidrig13:08:56

@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.

rickmoynihan14:08:08

a legend would be useful

rickmoynihan14:08:53

but yes that makes sense

ordnungswidrig19:08:02

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

ordnungswidrig19:08:14

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

rickmoynihan22:08:13

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