Returning HTMX or JSON in one endpoint #2686
-
SummaryHello, I've just started using I would like to serve JSON and HTMX responses from a similar endpoint, but without duplicating the code. I would also like to gate it on a header like
This is a bit of a mess because I don't get free deserialisation on the input, and it's pretty confused in a type-sense as to what it's returning. I also have to have two different ways of deciphering that data, form-wise and data-wise. I could have two separate functions, like How do other people deal with this? Note While we are open for sponsoring on GitHub Sponsors and Check out all issues funded or available for funding on our Polar.sh Litestar dashboard
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
I agree, but this is how I deal with it personally at work because if I did these weird mixins I lose out of some features and clear concern separation. I hate it (the duplication) too, tbf. |
Beta Was this translation helpful? Give feedback.
I agree, but this is how I deal with it personally at work because if I did these weird mixins I lose out of some features and clear concern separation. I hate it (the duplication) too, tbf.