2018-05-24 19:13:55 +02:00
|
|
|
// <ext>
|
2019-06-19 06:20:50 +02:00
|
|
|
use actix_web::{web, App, HttpRequest, Responder};
|
2018-05-24 19:13:55 +02:00
|
|
|
|
2019-06-17 10:12:11 +02:00
|
|
|
fn index(req: HttpRequest) -> impl Responder {
|
|
|
|
let url = req.url_for("youtube", &["oHg5SJYRHA0"]).unwrap();
|
2018-05-24 19:13:55 +02:00
|
|
|
assert_eq!(url.as_str(), "https://youtube.com/watch/oHg5SJYRHA0");
|
2019-06-17 10:12:11 +02:00
|
|
|
|
|
|
|
url.into_string()
|
2018-05-24 19:13:55 +02:00
|
|
|
}
|
|
|
|
|
2019-06-17 10:12:11 +02:00
|
|
|
pub fn main() {
|
2019-06-17 08:08:42 +02:00
|
|
|
App::new()
|
2019-06-17 10:12:11 +02:00
|
|
|
.route("/index.html", web::get().to(index))
|
|
|
|
.external_resource("youtube", "https://youtube.com/watch/{video_id}")
|
|
|
|
.route("/", actix_web::web::get().to(index));
|
2018-05-24 19:13:55 +02:00
|
|
|
}
|
|
|
|
// </ext>
|