Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

:known-content-types key? #261

Open
vspinu opened this issue Jun 21, 2016 · 4 comments
Open

:known-content-types key? #261

vspinu opened this issue Jun 21, 2016 · 4 comments

Comments

@vspinu
Copy link

vspinu commented Jun 21, 2016

I wonder if :known-content-type? check is standard enough such that a list of :known-content-types would be warranted? This would parallel :available-media-types and :media-type-available? usage.

@ordnungswidrig
Copy link
Member

liberator.presentation.parsable-content-type? is a function that contains checks if the request content-type is parsable by parse-request-entity. So if you want to make use of parse-request-entity then set :known-content-type? to that function.

@vspinu
Copy link
Author

vspinu commented Jun 22, 2016

This solution would also require parsing the json which I don't want to do before processable? node.

Also the doc says "parsed by the default implementation for :processable?". Following the main docs, :processable? is constant true and no parsing happens in there by default, or does it?

I basically was hoping for something like this

(defresource my-resource
  :allowed-methods [:get :post]
  :available-media-types ["application/json"]
  :known-content-types ["application/json"]
 ...

Instead of

(defresource my-resource
  :allowed-methods [:get :post]
  :available-media-types ["application/json"]
  :known-content-type? #(check-content-type % ["application/json"])

as suggested in the tutorial.

In any case, it's a small point. Feel free to close if you think it's not worth the flame.

@ordnungswidrig
Copy link
Member

I see, and I did not get your actual intention in the beginning. What you suggest is a good idea and independent of the entity parsing I suggested.

I will happily apply a PR for :known-content-types.

@cch1
Copy link
Contributor

cch1 commented Jan 28, 2017

As a new liberator user, I too found the tutorial surprisingly verbose and inefficient on this subject. Having a means of expressing the acceptability of request content types with data is a plus.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants