guzba / mummy

An HTTP and WebSocket server for Nim that returns to the ancient ways of threads.
MIT License
274 stars 10 forks source link

multipart response example/feature expansion? #74

Closed ITwrx closed 1 year ago

ITwrx commented 1 year ago

i'm not sure how to handle redirects after a posted form fails my validation. i have a sequence of error objects i need to respond with, preferably with posted input, along with a failure/success message (from session?), but i'm not sure how i'm supposed to do all that. All i see is a body string just like in the request, and i'm not sure how to use that for the above detailed needs. I wouldn't have known how to parse that body string from the request without that multipart example either. :)

ps. BTW, I used the multipart example even though i didn't need to upload a file, as i wasn't sure if a regular url-encoded form post request was supported, or how to handle it.

thanks

ITwrx commented 1 year ago

i'm going to close this for now, as i forgot/didn't realize that both form validation errors and old input should probably just be flashed to the session and retrieved from there, and would be outside the scope of the response object.

guzba commented 1 year ago

I need to set up an example for regular form-encoded bodies. It is a todo list item. Multipart is imo best avoided unless you need file uploads, though there is no harm in using it, it is just more complex under the hood.