You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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?
The text was updated successfully, but these errors were encountered:
sheepduke
changed the title
Provide helper function for returning a list of data
Provide helper function for returning a list of data?
Mar 31, 2023
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?
The text was updated successfully, but these errors were encountered: