Gene Kuo

According to https://api.rocket.rs/master/rocket/response/struct.Redirect.html, it recommends Redirect::to("/other_url") or Redirect::temporary("/other_url") be used to implement your requirements, which returns status code 303 and 307 respectively, with the location header set as the other_url. For example:

#[post("/", format ="application/json", data = "<new_post>")]

pub fn create_post(new_post: Json<NewPost>, _connection: DbConn) -> Redirect {

...

Redirect::to(format!("/new?title={}", Uri::percent_encode(new_post.title.as_str())))

}

And the response will similar to the following:

< HTTP/1.1 303 See Other

< Location: /new?title=Rust%20microservices

< Server: Rocket

< Content-Length: 0

...

Thanks for reading.

--

--

Gene Kuo

Gene Kuo

Solutions Architect, AWS CSAA/CDA: microservices, kubernetes, algorithms, Java, Rust, Golang, React, JavaScript…