:wave::upside_down_face:. <@U5E8TM9MW> All heade...
# http4k
d
👋🙃. @andyg All header lenses are bidi by default. Can you post a gist of what you're having trouble with
a
ok I have a BiDiBodyLens like:
val myBodyLens : BiDiBodyLens<MyObjectType> = Body.auto<MyObjectType>().toLens()
and I can enforce json serialization in a response with:
myBodyLens.inject(myObject, Response(Status.OK))
but I want to extend the "contract" via Lenses so that the Response MUST have a specific header
d
Aha ok: it's not something we've really thought about, but I suppose you could write something generic by following the pattern from body.auto (which sets the content type and the body content). I might also have a play and see if I can come up with something:
a
I wasn't aware that body.auto sets the content type... to application/json I assume? I don't see that in the docs, I even read
Q. Where is the Body.auto method defined?
and still can't find the code.
ok I did find the code, and i also see that
defaultContentType
is indeed
APPLICATION_JSON
... can I suggest adding that info to the json docs page? https://www.http4k.org/guide/modules/json/ thanks
d
You can certainly suggest it. And even better, the page is here for a PR to add. 😉 https://github.com/http4k/http4k/blob/master/src/docs/guide/modules/json/index.md
a
Done! Happy to contribute in a (very) small way. Feel free to edit my code example.
d
Thanks! Will take a look this morning. 🙃