mirror of
https://github.com/actix/actix-website
synced 2025-02-17 18:23:31 +01:00
17 lines
490 B
Rust
17 lines
490 B
Rust
|
// <ext>
|
||
|
use actix_web::{App, Error, HttpRequest, HttpResponse};
|
||
|
|
||
|
fn index(mut req: HttpRequest) -> Result<HttpResponse, Error> {
|
||
|
let url = req.url_for("youtube", &["oHg5SJYRHA0"])?;
|
||
|
assert_eq!(url.as_str(), "https://youtube.com/watch/oHg5SJYRHA0");
|
||
|
Ok(HttpResponse::Ok().into())
|
||
|
}
|
||
|
|
||
|
fn main() {
|
||
|
let app = App::new()
|
||
|
.resource("/index.html", |r| r.f(index))
|
||
|
.external_resource("youtube", "https://youtube.com/watch/{video_id}")
|
||
|
.finish();
|
||
|
}
|
||
|
// </ext>
|