Skip to content

Extended examples - #35

Open
tarassel wants to merge 9 commits into
metosin:masterfrom
tarassel:extended_examples
Open

Extended examples#35
tarassel wants to merge 9 commits into
metosin:masterfrom
tarassel:extended_examples

Conversation

@tarassel

Copy link
Copy Markdown

Proposing a new project with example of extended config usage.
Provided a variation how to set Get and Post on the same url but have different handlers.
Also there are examples of error handling and interceptors.

Comment thread examples/get-post/src/get_post/core.clj Outdated
"handles both requests"
[get-params post-params request]
(if (= (:request-method request) :get)
(s/with-fn-validation (get-handler get-params))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with-fn-validation is not thread-safe

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is kekkonen.core/input-coerce! that can be used for this => uses the registered http-coercions and produces identical errors than the standard coercion.

@ikitommi

ikitommi commented Jul 1, 2016

Copy link
Copy Markdown
Member

Thanks for the PR. I think it the support for multiple different http-methods should be implemented in the ring-adapter so that the api meta datas are in sync so that a) coherent validation exceptions are thrown and b) schema docs are in sync.

Added for comment to the source.

@tarassel

tarassel commented Jul 3, 2016

Copy link
Copy Markdown
Author

Some help with kekkonen.core/input-coerce! would be helpful.
Thanks.

@tarassel

tarassel commented Jul 3, 2016

Copy link
Copy Markdown
Author

Ok, I agree having support for multiple different http-methods in this way is not the best but at least it shows how to use config to bend library to your needs.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants