Hello, I've been trying to do this for a while. It's a hobby. Not a real project, but I'm stuck. Right now I don't even care that the code blocks until it reads the body, the problem is: it's blocking forever!
It's blocking when I do .wait() and it never returns
My testing data is:
curl -X POST -H "Content-Length: 34" -i http://127.0.0.1:8080/get-token -d'{"user":"Mr1","password":"123123"}'
Any ideas? Of course I obviously prefer non-blocking code, but I'm starting with Rust and Hyper, so even this code is turning out to be challenging.
I was able to "fix" the problem with the solutions posted here:
I had several problems in my code. The main problem was that I didn't need to wait. I could have just returned a future like in the examples below. The other problem (the reason I didn't do it like the examples below on the first place) was that, when I used something similar to the code in the examples below, I was boxing the entire match(){}... and that returned a compilation error because it was expecting a FutureResult and found a future::AndThen.
Moving the Box::new() inside the "match" fixed the problem I had while trying to return a future (something I tried and I couldn't get to compile)
The thing is... I don't really understand how moving the Box::new() inside the match code changes the end result so it compiles. So... I'm still looking for anyone to explain how that code change compiles in one way and not the other.
Thank you!
Here is the code for future reference:
With CpuPool