mirror of
https://github.com/actix/actix-website
synced 2025-02-08 22:36:07 +01:00
Update url-dispatch
This commit is contained in:
parent
1d6ccff3e8
commit
7a973d6fe9
@ -407,24 +407,24 @@ with `App::service()` method.
|
|||||||
{{< include-example example="url-dispatch" file="dhandler.rs" section="default" >}}
|
{{< include-example example="url-dispatch" file="dhandler.rs" section="default" >}}
|
||||||
|
|
||||||
[handlersection]: ../handlers/
|
[handlersection]: ../handlers/
|
||||||
[approute]: https://docs.rs/actix-web/1.0.2/actix_web/struct.App.html#method.route
|
[approute]: https://docs.rs/actix-web/2/actix_web/struct.App.html#method.route
|
||||||
[appservice]: https://docs.rs/actix-web/1.0.2/actix_web/struct.App.html?search=#method.service
|
[appservice]: https://docs.rs/actix-web/2/actix_web/struct.App.html?search=#method.service
|
||||||
[webresource]: https://docs.rs/actix-web/1.0.2/actix_web/struct.Resource.html
|
[webresource]: https://docs.rs/actix-web/2/actix_web/struct.Resource.html
|
||||||
[resourcehandler]: https://docs.rs/actix-web/1.0.2/actix_web/struct.Resource.html#method.route
|
[resourcehandler]: https://docs.rs/actix-web/2/actix_web/struct.Resource.html#method.route
|
||||||
[route]: https://docs.rs/actix-web/1.0.2/actix_web/struct.Route.html
|
[route]: https://docs.rs/actix-web/2/actix_web/struct.Route.html
|
||||||
[routeguard]: https://docs.rs/actix-web/1.0.2/actix_web/struct.Route.html#method.guard
|
[routeguard]: https://docs.rs/actix-web/2/actix_web/struct.Route.html#method.guard
|
||||||
[routemethod]: https://docs.rs/actix-web/1.0.2/actix_web/struct.Route.html#method.method
|
[routemethod]: https://docs.rs/actix-web/2/actix_web/struct.Route.html#method.method
|
||||||
[routeto]: https://docs.rs/actix-web/1.0.2/actix_web/struct.Route.html#method.to
|
[routeto]: https://docs.rs/actix-web/2/actix_web/struct.Route.html#method.to
|
||||||
[routetoasync]: https://docs.rs/actix-web/1.0.2/actix_web/struct.Route.html#method.to_async
|
[routetoasync]: https://docs.rs/actix-web/2/actix_web/struct.Route.html#method.to_async
|
||||||
[matchinfo]: https://docs.rs/actix-web/1.0.2/actix_web/struct.HttpRequest.html#method.match_info
|
[matchinfo]: https://docs.rs/actix-web/2/actix_web/struct.HttpRequest.html#method.match_info
|
||||||
[pathget]: https://docs.rs/actix-web/1.0.2/actix_web/dev/struct.Path.html#method.get
|
[pathget]: https://docs.rs/actix-web/2/actix_web/dev/struct.Path.html#method.get
|
||||||
[pathstruct]: https://docs.rs/actix-web/1.0.2/actix_web/dev/struct.Path.html
|
[pathstruct]: https://docs.rs/actix-web/2/actix_web/dev/struct.Path.html
|
||||||
[query]: https://docs.rs/actix-web/1.0.2/actix_web/web/struct.Query.html
|
[query]: https://docs.rs/actix-web/2/actix_web/web/struct.Query.html
|
||||||
[urlfor]: https://docs.rs/actix-web/1.0.2/actix_web/struct.HttpRequest.html#method.url_for
|
[urlfor]: https://docs.rs/actix-web/2/actix_web/struct.HttpRequest.html#method.url_for
|
||||||
[urlobj]: https://docs.rs/url/1.7.2/url/struct.Url.html
|
[urlobj]: https://docs.rs/url/1.7.2/url/struct.Url.html
|
||||||
[guardtrait]: https://docs.rs/actix-web/1.0.2/actix_web/guard/trait.Guard.html
|
[guardtrait]: https://docs.rs/actix-web/2/actix_web/guard/trait.Guard.html
|
||||||
[guardfuncs]: https://docs.rs/actix-web/1.0.2/actix_web/guard/index.html#functions
|
[guardfuncs]: https://docs.rs/actix-web/2/actix_web/guard/index.html#functions
|
||||||
[requestextensions]: https://docs.rs/actix-web/1.0.2/actix_web/struct.HttpRequest.html#method.extensions
|
[requestextensions]: https://docs.rs/actix-web/2/actix_web/struct.HttpRequest.html#method.extensions
|
||||||
[implfromrequest]: https://docs.rs/actix-web/1.0.2/actix_web/trait.FromRequest.html
|
[implfromrequest]: https://docs.rs/actix-web/2/actix_web/trait.FromRequest.html
|
||||||
[implresponder]: https://docs.rs/actix-web/1.0.2/actix_web/trait.Responder.html
|
[implresponder]: https://docs.rs/actix-web/2/actix_web/trait.Responder.html
|
||||||
[pathextractor]: ../extractors
|
[pathextractor]: ../extractors
|
||||||
|
@ -5,8 +5,9 @@ edition = "2018"
|
|||||||
workspace = "../"
|
workspace = "../"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
actix = "0.8"
|
actix = "0.9"
|
||||||
actix-web = "1.0"
|
actix-rt = "1.0"
|
||||||
futures = "0.1"
|
actix-web = "2.0"
|
||||||
|
futures = "0.3.1"
|
||||||
openssl = "0.10"
|
openssl = "0.10"
|
||||||
serde = "1.0"
|
serde = "1.0"
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
use actix_web::{guard, web, App, HttpResponse};
|
use actix_web::{guard, web, App, HttpResponse};
|
||||||
|
|
||||||
#[rustfmt::skip]
|
#[rustfmt::skip]
|
||||||
pub fn main() {
|
#[actix_rt::main]
|
||||||
|
async fn main() -> std::io::Result<()> {
|
||||||
use actix_web::HttpServer;
|
use actix_web::HttpServer;
|
||||||
|
|
||||||
HttpServer::new(|| {
|
HttpServer::new(|| {
|
||||||
@ -16,8 +17,7 @@ App::new().service(
|
|||||||
)
|
)
|
||||||
// </cfg>
|
// </cfg>
|
||||||
})
|
})
|
||||||
.bind("127.0.0.1:8088")
|
.bind("127.0.0.1:8088")?
|
||||||
.unwrap()
|
|
||||||
.run()
|
.run()
|
||||||
.unwrap();
|
.await
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
use actix_web::{guard, web, App, HttpRequest, HttpResponse, HttpServer, Responder};
|
use actix_web::{guard, web, App, HttpRequest, HttpResponse, HttpServer, Responder};
|
||||||
|
|
||||||
fn index(_req: HttpRequest) -> impl Responder {
|
async fn index(_req: HttpRequest) -> impl Responder {
|
||||||
"Welcome!"
|
"Welcome!"
|
||||||
}
|
}
|
||||||
|
|
||||||
// <default>
|
// <default>
|
||||||
pub fn main() {
|
#[actix_rt::main]
|
||||||
|
async fn main() -> std::io::Result<()> {
|
||||||
HttpServer::new(|| {
|
HttpServer::new(|| {
|
||||||
App::new()
|
App::new()
|
||||||
.service(web::resource("/").route(web::get().to(index)))
|
.service(web::resource("/").route(web::get().to(index)))
|
||||||
@ -15,9 +16,8 @@ pub fn main() {
|
|||||||
.to(|| HttpResponse::MethodNotAllowed()),
|
.to(|| HttpResponse::MethodNotAllowed()),
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
.bind("127.0.0.1:8088")
|
.bind("127.0.0.1:8088")?
|
||||||
.unwrap()
|
|
||||||
.run()
|
.run()
|
||||||
.unwrap();
|
.await
|
||||||
}
|
}
|
||||||
// </default>
|
// </default>
|
||||||
|
@ -9,7 +9,8 @@ impl Guard for ContentTypeHeader {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn main() {
|
#[actix_rt::main]
|
||||||
|
async fn main() -> std::io::Result<()> {
|
||||||
use actix_web::{web, App, HttpServer};
|
use actix_web::{web, App, HttpServer};
|
||||||
|
|
||||||
HttpServer::new(|| {
|
HttpServer::new(|| {
|
||||||
@ -20,9 +21,8 @@ pub fn main() {
|
|||||||
.to(|| HttpResponse::Ok()),
|
.to(|| HttpResponse::Ok()),
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
.bind("127.0.0.1:8088")
|
.bind("127.0.0.1:8088")?
|
||||||
.unwrap()
|
|
||||||
.run()
|
.run()
|
||||||
.unwrap();
|
.await
|
||||||
}
|
}
|
||||||
// </guard>
|
// </guard>
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
// <guard2>
|
// <guard2>
|
||||||
use actix_web::{guard, web, App, HttpResponse, HttpServer};
|
use actix_web::{guard, web, App, HttpResponse, HttpServer};
|
||||||
|
|
||||||
pub fn main() {
|
#[actix_rt::main]
|
||||||
|
async fn main() -> std::io::Result<()> {
|
||||||
HttpServer::new(|| {
|
HttpServer::new(|| {
|
||||||
App::new().route(
|
App::new().route(
|
||||||
"/",
|
"/",
|
||||||
@ -10,9 +11,8 @@ pub fn main() {
|
|||||||
.to(|| HttpResponse::MethodNotAllowed()),
|
.to(|| HttpResponse::MethodNotAllowed()),
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
.bind("127.0.0.1:8088")
|
.bind("127.0.0.1:8088")?
|
||||||
.unwrap()
|
|
||||||
.run()
|
.run()
|
||||||
.unwrap();
|
.await
|
||||||
}
|
}
|
||||||
// </guard2>
|
// </guard2>
|
||||||
|
@ -16,19 +16,19 @@ pub mod urls;
|
|||||||
// <main>
|
// <main>
|
||||||
use actix_web::{web, App, HttpResponse, HttpServer};
|
use actix_web::{web, App, HttpResponse, HttpServer};
|
||||||
|
|
||||||
fn index() -> HttpResponse {
|
async fn index() -> HttpResponse {
|
||||||
HttpResponse::Ok().body("Hello")
|
HttpResponse::Ok().body("Hello")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
#[actix_rt::main]
|
||||||
|
async fn main() -> std::io::Result<()> {
|
||||||
HttpServer::new(|| {
|
HttpServer::new(|| {
|
||||||
App::new()
|
App::new()
|
||||||
.route("/", web::get().to(index))
|
.route("/", web::get().to(index))
|
||||||
.route("/user", web::post().to(index))
|
.route("/user", web::post().to(index))
|
||||||
})
|
})
|
||||||
.bind("127.0.0.1:8088")
|
.bind("127.0.0.1:8088")?
|
||||||
.unwrap()
|
|
||||||
.run()
|
.run()
|
||||||
.unwrap();
|
.await
|
||||||
}
|
}
|
||||||
// </main>
|
// </main>
|
||||||
|
@ -1,14 +1,15 @@
|
|||||||
// <minfo>
|
// <minfo>
|
||||||
use actix_web::{HttpRequest, HttpResponse, Result};
|
use actix_web::{HttpRequest, HttpResponse, Result};
|
||||||
|
|
||||||
fn index(req: HttpRequest) -> Result<String> {
|
async fn index(req: HttpRequest) -> Result<String> {
|
||||||
let v1: u8 = req.match_info().get("v1").unwrap().parse().unwrap();
|
let v1: u8 = req.match_info().get("v1").unwrap().parse().unwrap();
|
||||||
let v2: u8 = req.match_info().query("v2").parse().unwrap();
|
let v2: u8 = req.match_info().query("v2").parse().unwrap();
|
||||||
let (v3, v4): (u8, u8) = req.match_info().load().unwrap();
|
let (v3, v4): (u8, u8) = req.match_info().load().unwrap();
|
||||||
Ok(format!("Values {} {} {} {}", v1, v2, v3, v4))
|
Ok(format!("Values {} {} {} {}", v1, v2, v3, v4))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn main() {
|
#[actix_rt::main]
|
||||||
|
async fn main() -> std::io::Result<()> {
|
||||||
use actix_web::{web, App, HttpServer};
|
use actix_web::{web, App, HttpServer};
|
||||||
|
|
||||||
HttpServer::new(|| {
|
HttpServer::new(|| {
|
||||||
@ -16,9 +17,8 @@ pub fn main() {
|
|||||||
.route("/a/{v1}/{v2}/", web::get().to(index))
|
.route("/a/{v1}/{v2}/", web::get().to(index))
|
||||||
.route("", web::get().to(|| HttpResponse::Ok()))
|
.route("", web::get().to(|| HttpResponse::Ok()))
|
||||||
})
|
})
|
||||||
.bind("127.0.0.1:8088")
|
.bind("127.0.0.1:8088")?
|
||||||
.unwrap()
|
|
||||||
.run()
|
.run()
|
||||||
.unwrap();
|
.await
|
||||||
}
|
}
|
||||||
// </minfo>
|
// </minfo>
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
// <norm>
|
// <norm>
|
||||||
use actix_web::{middleware, HttpResponse};
|
use actix_web::{middleware, HttpResponse};
|
||||||
|
|
||||||
fn index() -> HttpResponse {
|
async fn index() -> HttpResponse {
|
||||||
HttpResponse::Ok().body("Hello")
|
HttpResponse::Ok().body("Hello")
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn main() {
|
#[actix_rt::main]
|
||||||
|
async fn main() -> std::io::Result<()> {
|
||||||
use actix_web::{web, App, HttpServer};
|
use actix_web::{web, App, HttpServer};
|
||||||
|
|
||||||
HttpServer::new(|| {
|
HttpServer::new(|| {
|
||||||
@ -13,9 +14,8 @@ pub fn main() {
|
|||||||
.wrap(middleware::NormalizePath)
|
.wrap(middleware::NormalizePath)
|
||||||
.route("/resource/", web::to(index))
|
.route("/resource/", web::to(index))
|
||||||
})
|
})
|
||||||
.bind("127.0.0.1:8088")
|
.bind("127.0.0.1:8088")?
|
||||||
.unwrap()
|
|
||||||
.run()
|
.run()
|
||||||
.unwrap();
|
.await
|
||||||
}
|
}
|
||||||
// </norm>
|
// </norm>
|
||||||
|
@ -7,16 +7,16 @@ fn index() -> HttpResponse {
|
|||||||
// <norm>
|
// <norm>
|
||||||
use actix_web::{http::Method, middleware, web, App, HttpServer};
|
use actix_web::{http::Method, middleware, web, App, HttpServer};
|
||||||
|
|
||||||
pub fn main() {
|
#[actix_rt::main]
|
||||||
|
async fn main() -> std::io::Result<()> {
|
||||||
HttpServer::new(|| {
|
HttpServer::new(|| {
|
||||||
App::new()
|
App::new()
|
||||||
.wrap(middleware::NormalizePath)
|
.wrap(middleware::NormalizePath)
|
||||||
.route("/resource/", web::get().to(index))
|
.route("/resource/", web::get().to(index))
|
||||||
.default_service(web::route().method(Method::GET))
|
.default_service(web::route().method(Method::GET))
|
||||||
})
|
})
|
||||||
.bind("127.0.0.1:8088")
|
.bind("127.0.0.1:8088")?
|
||||||
.unwrap()
|
|
||||||
.run()
|
.run()
|
||||||
.unwrap();
|
.await
|
||||||
}
|
}
|
||||||
// </norm>
|
// </norm>
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
// <path>
|
// <path>
|
||||||
use actix_web::{web, Result};
|
use actix_web::{web, Result};
|
||||||
|
|
||||||
fn index(info: web::Path<(String, u32)>) -> Result<String> {
|
async fn index(info: web::Path<(String, u32)>) -> Result<String> {
|
||||||
Ok(format!("Welcome {}! id: {}", info.0, info.1))
|
Ok(format!("Welcome {}! id: {}", info.0, info.1))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn main() {
|
#[actix_rt::main]
|
||||||
|
async fn main() -> std::io::Result<()> {
|
||||||
use actix_web::{App, HttpServer};
|
use actix_web::{App, HttpServer};
|
||||||
|
|
||||||
HttpServer::new(|| {
|
HttpServer::new(|| {
|
||||||
@ -14,9 +15,8 @@ pub fn main() {
|
|||||||
web::get().to(index),
|
web::get().to(index),
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
.bind("127.0.0.1:8088")
|
.bind("127.0.0.1:8088")?
|
||||||
.unwrap()
|
|
||||||
.run()
|
.run()
|
||||||
.unwrap();
|
.await
|
||||||
}
|
}
|
||||||
// </path>
|
// </path>
|
||||||
|
@ -8,11 +8,12 @@ struct Info {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// extract path info using serde
|
// extract path info using serde
|
||||||
fn index(info: web::Path<Info>) -> Result<String> {
|
async fn index(info: web::Path<Info>) -> Result<String> {
|
||||||
Ok(format!("Welcome {}!", info.username))
|
Ok(format!("Welcome {}!", info.username))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn main() {
|
#[actix_rt::main]
|
||||||
|
async fn main() -> std::io::Result<()> {
|
||||||
use actix_web::{App, HttpServer};
|
use actix_web::{App, HttpServer};
|
||||||
|
|
||||||
HttpServer::new(|| {
|
HttpServer::new(|| {
|
||||||
@ -21,9 +22,8 @@ pub fn main() {
|
|||||||
web::get().to(index),
|
web::get().to(index),
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
.bind("127.0.0.1:8088")
|
.bind("127.0.0.1:8088")?
|
||||||
.unwrap()
|
|
||||||
.run()
|
.run()
|
||||||
.unwrap();
|
.await
|
||||||
}
|
}
|
||||||
// </path>
|
// </path>
|
||||||
|
@ -2,18 +2,18 @@
|
|||||||
use actix_web::{HttpRequest, Result};
|
use actix_web::{HttpRequest, Result};
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
fn index(req: HttpRequest) -> Result<String> {
|
async fn index(req: HttpRequest) -> Result<String> {
|
||||||
let path: PathBuf = req.match_info().query("tail").parse().unwrap();
|
let path: PathBuf = req.match_info().query("tail").parse().unwrap();
|
||||||
Ok(format!("Path {:?}", path))
|
Ok(format!("Path {:?}", path))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn main() {
|
#[actix_rt::main]
|
||||||
|
async fn main() -> std::io::Result<()> {
|
||||||
use actix_web::{web, App, HttpServer};
|
use actix_web::{web, App, HttpServer};
|
||||||
|
|
||||||
HttpServer::new(|| App::new().route(r"/a/{tail:.*}", web::get().to(index)))
|
HttpServer::new(|| App::new().route(r"/a/{tail:.*}", web::get().to(index)))
|
||||||
.bind("127.0.0.1:8088")
|
.bind("127.0.0.1:8088")?
|
||||||
.unwrap()
|
|
||||||
.run()
|
.run()
|
||||||
.unwrap();
|
.await
|
||||||
}
|
}
|
||||||
// </pbuf>
|
// </pbuf>
|
||||||
|
@ -1,15 +1,16 @@
|
|||||||
use actix_web::{web, App, HttpResponse, HttpServer};
|
use actix_web::{web, App, HttpResponse, HttpServer};
|
||||||
|
|
||||||
// <scope>
|
// <scope>
|
||||||
fn show_users() -> HttpResponse {
|
async fn show_users() -> HttpResponse {
|
||||||
HttpResponse::Ok().body("Show users")
|
HttpResponse::Ok().body("Show users")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn user_detail(path: web::Path<(u32,)>) -> HttpResponse {
|
async fn user_detail(path: web::Path<(u32,)>) -> HttpResponse {
|
||||||
HttpResponse::Ok().body(format!("User detail: {}", path.0))
|
HttpResponse::Ok().body(format!("User detail: {}", path.0))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn main() {
|
#[actix_rt::main]
|
||||||
|
async fn main() -> std::io::Result<()> {
|
||||||
HttpServer::new(|| {
|
HttpServer::new(|| {
|
||||||
App::new().service(
|
App::new().service(
|
||||||
web::scope("/users")
|
web::scope("/users")
|
||||||
@ -17,9 +18,8 @@ pub fn main() {
|
|||||||
.route("/show/{id}", web::get().to(user_detail)),
|
.route("/show/{id}", web::get().to(user_detail)),
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
.bind("127.0.0.1:8088")
|
.bind("127.0.0.1:8088")?
|
||||||
.unwrap()
|
|
||||||
.run()
|
.run()
|
||||||
.unwrap();
|
.await
|
||||||
}
|
}
|
||||||
// </scope>
|
// </scope>
|
||||||
|
@ -1,14 +1,15 @@
|
|||||||
// <ext>
|
// <ext>
|
||||||
use actix_web::{HttpRequest, Responder};
|
use actix_web::{HttpRequest, Responder};
|
||||||
|
|
||||||
fn index(req: HttpRequest) -> impl Responder {
|
async fn index(req: HttpRequest) -> impl Responder {
|
||||||
let url = req.url_for("youtube", &["oHg5SJYRHA0"]).unwrap();
|
let url = req.url_for("youtube", &["oHg5SJYRHA0"]).unwrap();
|
||||||
assert_eq!(url.as_str(), "https://youtube.com/watch/oHg5SJYRHA0");
|
assert_eq!(url.as_str(), "https://youtube.com/watch/oHg5SJYRHA0");
|
||||||
|
|
||||||
url.into_string()
|
url.into_string()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn main() {
|
#[actix_rt::main]
|
||||||
|
async fn main() -> std::io::Result<()> {
|
||||||
use actix_web::{web, App, HttpServer};
|
use actix_web::{web, App, HttpServer};
|
||||||
|
|
||||||
HttpServer::new(|| {
|
HttpServer::new(|| {
|
||||||
@ -17,9 +18,8 @@ pub fn main() {
|
|||||||
.external_resource("youtube", "https://youtube.com/watch/{video_id}")
|
.external_resource("youtube", "https://youtube.com/watch/{video_id}")
|
||||||
.route("/", actix_web::web::get().to(index))
|
.route("/", actix_web::web::get().to(index))
|
||||||
})
|
})
|
||||||
.bind("127.0.0.1:8088")
|
.bind("127.0.0.1:8088")?
|
||||||
.unwrap()
|
|
||||||
.run()
|
.run()
|
||||||
.unwrap();
|
.await
|
||||||
}
|
}
|
||||||
// </ext>
|
// </ext>
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// <url>
|
// <url>
|
||||||
use actix_web::{guard, http::header, HttpRequest, HttpResponse, Result};
|
use actix_web::{guard, http::header, HttpRequest, HttpResponse, Result};
|
||||||
|
|
||||||
fn index(req: HttpRequest) -> Result<HttpResponse> {
|
async fn index(req: HttpRequest) -> Result<HttpResponse> {
|
||||||
let url = req.url_for("foo", &["1", "2", "3"])?; // <- generate url for "foo" resource
|
let url = req.url_for("foo", &["1", "2", "3"])?; // <- generate url for "foo" resource
|
||||||
|
|
||||||
Ok(HttpResponse::Found()
|
Ok(HttpResponse::Found()
|
||||||
@ -9,7 +9,8 @@ fn index(req: HttpRequest) -> Result<HttpResponse> {
|
|||||||
.finish())
|
.finish())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn main() {
|
#[actix_rt::main]
|
||||||
|
async fn main() -> std::io::Result<()> {
|
||||||
use actix_web::{web, App, HttpServer};
|
use actix_web::{web, App, HttpServer};
|
||||||
|
|
||||||
HttpServer::new(|| {
|
HttpServer::new(|| {
|
||||||
@ -22,9 +23,8 @@ pub fn main() {
|
|||||||
)
|
)
|
||||||
.route("/test/", web::get().to(index))
|
.route("/test/", web::get().to(index))
|
||||||
})
|
})
|
||||||
.bind("127.0.0.1:8088")
|
.bind("127.0.0.1:8088")?
|
||||||
.unwrap()
|
|
||||||
.run()
|
.run()
|
||||||
.unwrap();
|
.await
|
||||||
}
|
}
|
||||||
// </url>
|
// </url>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user