You know lack requires the response to be a pathname, a byte array, a single string or a list of (state headers content). Weirdly the content itself has to be a list. Despite that, what if you simply want to return a list of objects as result? If you directly return it from a route handler, it will be recognized by lack as the last case and an error is signaled.
I know the macro (jingle:with-json-response), but it is locked in jonathan. Also, I think it is better to handle JSON serialization in a middleware, just like how status codes like 404 are handled.
Having said that, what I did was writing a helper function to wrap the list data in a valid lack response list, then use a middleware to handle JSON serialization.
Do you have any idea about it? How can this part be made more dev-friendly?
You know
lack
requires the response to be a pathname, a byte array, a single string or a list of(state headers content)
. Weirdly the content itself has to be a list. Despite that, what if you simply want to return a list of objects as result? If you directly return it from a route handler, it will be recognized bylack
as the last case and an error is signaled.I know the macro
(jingle:with-json-response)
, but it is locked injonathan
. Also, I think it is better to handle JSON serialization in a middleware, just like how status codes like 404 are handled.Having said that, what I did was writing a helper function to wrap the list data in a valid
lack
response list, then use a middleware to handle JSON serialization.Do you have any idea about it? How can this part be made more dev-friendly?