Hacker News new | ask | show | jobs
by renewiltord 1999 days ago
Hey, thank you for offering. Yes! Something minimal like that that doesn't use `reqwest::blocking` would be very helpful.

If it could do the Error case too that would be cool.

For Rocket, I have something like:

    #[get("/list/<status>")]
    fn list_prospects(api_key: ApiKey, status: String) -> Result<Json<PendingList>, Status>
with a

    impl<'a, 'r> FromRequest<'a, 'r> for ApiKey
But I couldn't quickly get an `async` piece in there so I just sucked it up and synced it all up since it's only backing a Retool dashboard so it isn't the end of the world.

So if the example is like:

    #[get('/todo')]
    fn get_todos() -> Result<Json<TodoList>, Status>
      let todos = reqwest...
      Ok(todos)
or the equivalent in the web framework you have that would be hecka useful.
1 comments

For Rocket you want to use the master branch which has async support. Then your request handler is an async function and you can just .await the future returned by reqwest.
Oh, I must be behind. Should've kept up and tried it. Thank you!