hapic
hapic copied to clipboard
Good practice to handle Accept header case ?
Hello, I was trying to use pyramid with hapic and marshmallow, and i do wanted to validate that origin user do accept "text/event-stream" as response using the Accept header.
My naive approach was to use @hapic.input_header()
and OneOf validator of marshmallow with one value "text/event-stream".
It's working, but i check spec of Accept:
https://developer.mozilla.org/fr/docs/Web/HTTP/Headers/Accept
i should also accept many complex case like:
-
*/*
-
text/*
-
text/event-stream, text/html, application/xhtml+xml, application/xml;q=0.9, */*;q=0.8