oscartbeaumont / httpz

Code once, support every Rust webserver!
MIT License
28 stars 4 forks source link

Support closures for handler function #5

Closed oscartbeaumont closed 2 years ago

oscartbeaumont commented 2 years ago

As far as I am aware this can't be expressed to the Rust compiler as the cookies argument to the HTTP handler is of type &mut CookieJar and the closure returns an async block that holds that reference.

If someone is galaxy brain and can fix this without requiring a heap allocation or reference counting (Box, Arc, Rc) I will be very thankful.

If this can be fixed we will remove the context system and rely on the closure capturing any state that the user wants in the handler.

oscartbeaumont commented 2 years ago

Passing the CookieJar by reference didn't scale so I've gone back to it being owned which fixes the lifetimes and allows using a closure.