Repository navigation
Replies: 2 comments 3 replies
|
Firstly there is a redirect responder already: https://api.rocket.rs/v0.5/rocket/response/struct.Redirect use rocket::response::Redirect;
#[get("/hello/<name>/<age>")]
fn hello(name: String, age: u8) -> String {
format!("Hello, {} year old named {}!", age, name)
}
#[get("/hi/<name>/<age>")]
fn hi(name: String, age: u8) -> Redirect {
Redirect::to(uri!(hello(name, age)))
}
#[get("/bye/<name>/<age>")]
fn bye(name: String, age: u8) -> Redirect {
Redirect::to(uri!("https://rocket.rs/bye", hello(name, age), "?bye#now"))
}For testing there are probably two main approached, first you could set up a 'system' test and use something like Robot Framework or Cucumber to test things are working. The other option would be to use the local client and inspect the response (https://api.rocket.rs/v0.5/rocket/local/). The local client would allow the test to live with the code. |
0 replies
|
I knew about the redirect responder :) but that also has to set that header
and yes, I wanted to use the local client, as outlined in the testing
section of the docs.
So the main problem I have is "how to parse a string according to a
template", something like "Uri::parse_into(&location_header,
details.route.uri)"
…On Fri, Jan 2, 2026, 18:06 Martyn P ***@***.***> wrote:
Firstly there is a redirect responder already:
https://api.rocket.rs/v0.5/rocket/response/struct.Redirect
use rocket::response::Redirect;
#[get("/hello/<name>/<age>")]fn hello(name: String, age: u8) -> String {
format!("Hello, {} year old named {}!", age, name)}
#[get("/hi/<name>/<age>")]fn hi(name: String, age: u8) -> Redirect {
Redirect::to(uri!(hello(name, age)))}
#[get("/bye/<name>/<age>")]fn bye(name: String, age: u8) -> Redirect {
Redirect::to(uri!("https://rocket.rs/bye", hello(name, age), "?bye#now"))}
For testing there are probably two main approached, first you could set up
a 'system' test and use something like Robot Framework or Cucumber to test
things are working.
The other option would be to use the local client and inspect the response
(https://api.rocket.rs/v0.5/rocket/local/). The local client would allow
the test to live with the code.
—
Reply to this email directly, view it on GitHub
<#2982 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACOHZTRXLZKD22MSW5NDHJD4E2QQVAVCNFSM6AAAAACQRE3H36VHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTKMZZGI2TGOA>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Assuming we have something like
how would I test that
put_fooactually includes aLocationheader with a value that matches the template forget_foo?I'm kinda new to rust as a whole but am loving it so far (shocker, I know ;) ) so sorry if I'm missing something obvious here.
All reactions