Open peffis opened 7 years ago
You'd probably be better off asking this in the Yaws mailing list, since more users will see it there than here, but I don't think you're missing any convenience functions, and I don't see anything wrong with the approach you're taking to reuse your functions.
When Yaws receives large POSTs and PUTs they are split into several calls to your out handler in your appmod. To handle the request you end up implementing a state machine - something like:
If you have several places in your code where you handle large POSTs and PUTs you end up copying around this state machine with some minor modifications of init_state, process_data and finalize_upload.
How are people in general handling this (not too worrying) code smell? When these four clause-groups occur too many times within the same project I usually end up making some parameterized function, like:
, which reduces the four clauses to one clause and allows some reuse of the state machine handling large uploads.
Is this in general how people handle this code smell or is there some other more conveniant handling of large POSTs and PUTs in the API that I have not noted yet?