Skip to content
\n

But I don't know if this is good idea and from a testing point of view it is also not ideal because the client should be easy to mock.

\n

IMO something like this would be great to have:

\n
#[get(\"/\")]\nasync fn index(client: Client) -> Result<String, Error> {\n    ...\n}
\n

then the framework is responsible for managing the http client and tests could just exchange the client with a mock.

\n

Is there something like this?

","upvoteCount":1,"answerCount":1,"acceptedAnswer":{"@type":"Answer","text":"

Yes: managed state.

","upvoteCount":2,"url":"https://github.com/rwf2/Rocket/discussions/2855#discussioncomment-10459491"}}}

Inject an HTTP Client #2855

Aug 27, 2024 · 1 comments · 3 replies
Discussion options

You must be logged in to vote

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@guenhter
Comment options

@the10thWiz
Comment options

@SergioBenitez
Comment options

Answer selected by the10thWiz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants