-
Notifications
You must be signed in to change notification settings - Fork 51
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
POST body: how to translate camel case JSON to Clojure kebab? #104
Comments
Duct uses Ring and the Muuntaja middleware to handle JSON, so you can do this in several different ways. You probably want to start with a key conversion library like camel-snake-kebab, and then either insert your own middleware, or more elegantly, update the options on the Muuntaja middleware. The Muuntaja middleware handles content negotiation, and is configured by the |
hi James, I am trying to "update the options on the Muuntaja middleware", as suggested. In REPL, everything seems to work fine till invocation to function
I try to implement that using integrant the following way: In
Implementation:
However, when running
Error fully reported:
What am I making wrong? Thanks in advance... Luis |
You have it almost right; you just need to put your keys into a profile: :duct.module.web/api {}
:duct.profile/base
{...
:authorizer.serializations/formats {}
:duct.middleware.web/format {:formats #ig/ref :authorizer.serializations/formats}} The outer configuration is for modules and profiles (which are currently a type of module). Non-module keys need to be put into a profile. The next version of Duct will change the design a little to make the distinction between component keys and module keys more obvious. |
It worked ! Thank you very much, James, for the quick, right replies ! Luis |
Hi,
I am implementing a little REST API with Duct / Integrant, following Duct's Guide and this tutorial.
POST body JSON described there is case agnostic, so it's not clear to me how to translate a typical camel case JSON into typical kebab case Clojure maps.
Thanks in advance !
Luis
https://promesante.github.io/
https://github.com/promesante
The text was updated successfully, but these errors were encountered: