2018-05-24 19:13:55 +02:00
|
|
|
// <ext>
|
2019-06-17 08:08:42 +02:00
|
|
|
use actix_web::{web, App, Error, HttpRequest, HttpResponse};
|
2018-05-24 19:13:55 +02:00
|
|
|
|
2019-06-17 08:08:42 +02:00
|
|
|
fn index(req: HttpRequest) -> Result<HttpResponse, Error> {
|
2018-05-24 19:13:55 +02:00
|
|
|
let url = req.url_for("youtube", &["oHg5SJYRHA0"])?;
|
|
|
|
assert_eq!(url.as_str(), "https://youtube.com/watch/oHg5SJYRHA0");
|
|
|
|
Ok(HttpResponse::Ok().into())
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
2019-06-17 08:08:42 +02:00
|
|
|
App::new()
|
|
|
|
.service(web::resource("/index.html").route(web::get().to(index)))
|
|
|
|
.external_resource("youtube", "https://youtube.com/watch/{video_id}");
|
2018-05-24 19:13:55 +02:00
|
|
|
}
|
|
|
|
// </ext>
|