mirror of
https://github.com/actix/actix-website
synced 2025-01-22 16:15:56 +01:00
use actix-web 0.7 for examples
This commit is contained in:
parent
324799dd2a
commit
5cd8d2edc8
@ -1,7 +1,7 @@
|
||||
[package]
|
||||
name = "application"
|
||||
version = "0.6.0"
|
||||
version = "0.7.0"
|
||||
workspace = "../"
|
||||
|
||||
[dependencies]
|
||||
actix-web = "0.6"
|
||||
actix-web = "0.7"
|
||||
|
@ -7,7 +7,7 @@ mod vh;
|
||||
|
||||
fn make_app() {
|
||||
// <make_app>
|
||||
fn index(req: HttpRequest) -> impl Responder {
|
||||
fn index(req: &HttpRequest) -> impl Responder {
|
||||
"Hello world!"
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,7 @@ struct AppState {
|
||||
counter: Cell<usize>,
|
||||
}
|
||||
|
||||
fn index(req: HttpRequest<AppState>) -> String {
|
||||
fn index(req: &HttpRequest<AppState>) -> String {
|
||||
let count = req.state().counter.get() + 1; // <- get count
|
||||
req.state().counter.set(count); // <- store new count in state
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
[package]
|
||||
name = "getting-started"
|
||||
version = "0.6.0"
|
||||
version = "0.7.0"
|
||||
workspace = "../"
|
||||
|
||||
[dependencies]
|
||||
actix-web = "0.6"
|
||||
actix-web = "0.7"
|
||||
|
@ -2,7 +2,7 @@
|
||||
extern crate actix_web;
|
||||
use actix_web::{server, App, HttpRequest};
|
||||
|
||||
fn index(_req: HttpRequest) -> &'static str {
|
||||
fn index(_req: &HttpRequest) -> &'static str {
|
||||
"Hello world!"
|
||||
}
|
||||
// </setup>
|
||||
|
@ -1,10 +1,10 @@
|
||||
[package]
|
||||
name = "server"
|
||||
version = "0.6.0"
|
||||
version = "0.7.0"
|
||||
workspace = "../"
|
||||
|
||||
[dependencies]
|
||||
actix = "0.5"
|
||||
actix-web = { version="0.6", features=["alpn"] }
|
||||
actix = "0.7"
|
||||
actix-web = { version="0.7", features=["alpn"] }
|
||||
futures = "0.1"
|
||||
openssl = "0.10"
|
||||
|
@ -2,7 +2,7 @@
|
||||
use actix_web::{server, App, HttpRequest, Responder};
|
||||
use openssl::ssl::{SslAcceptor, SslFiletype, SslMethod};
|
||||
|
||||
fn index(req: HttpRequest) -> impl Responder {
|
||||
fn index(req: &HttpRequest) -> impl Responder {
|
||||
"Welcome!"
|
||||
}
|
||||
|
||||
|
@ -1,11 +1,11 @@
|
||||
[package]
|
||||
name = "url-dispatch"
|
||||
version = "0.6.0"
|
||||
version = "0.7.0"
|
||||
workspace = "../"
|
||||
|
||||
[dependencies]
|
||||
actix = "0.5"
|
||||
actix-web = "0.6"
|
||||
actix = "0.7"
|
||||
actix-web = "0.7"
|
||||
futures = "0.1"
|
||||
openssl = "0.10"
|
||||
serde = "1.0"
|
||||
|
@ -1,7 +1,7 @@
|
||||
// <minfo>
|
||||
use actix_web::{App, HttpRequest, Result};
|
||||
|
||||
fn index(req: HttpRequest) -> Result<String> {
|
||||
fn index(req: &HttpRequest) -> Result<String> {
|
||||
let v1: u8 = req.match_info().query("v1")?;
|
||||
let v2: u8 = req.match_info().query("v2")?;
|
||||
Ok(format!("Values {} {}", v1, v2))
|
||||
|
@ -10,6 +10,6 @@ fn main() {
|
||||
// </norm>
|
||||
|
||||
use actix_web::HttpRequest;
|
||||
fn index(req: HttpRequest) -> String {
|
||||
fn index(req: &HttpRequest) -> String {
|
||||
unimplemented!()
|
||||
}
|
||||
|
@ -11,6 +11,6 @@ fn main() {
|
||||
|
||||
use actix_web::HttpRequest;
|
||||
|
||||
fn index(req: HttpRequest) -> String {
|
||||
fn index(req: &HttpRequest) -> String {
|
||||
unimplemented!()
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
use actix_web::{http::Method, App, HttpRequest, Result};
|
||||
use std::path::PathBuf;
|
||||
|
||||
fn index(req: HttpRequest) -> Result<String> {
|
||||
fn index(req: &HttpRequest) -> Result<String> {
|
||||
let path: PathBuf = req.match_info().query("tail")?;
|
||||
Ok(format!("Path {:?}", path))
|
||||
}
|
||||
|
@ -1,10 +1,10 @@
|
||||
// <pred>
|
||||
use actix_web::{http, pred::Predicate, App, HttpMessage, HttpRequest, HttpResponse};
|
||||
use actix_web::{http, server::Request, pred::Predicate, App, HttpResponse};
|
||||
|
||||
struct ContentTypeHeader;
|
||||
|
||||
impl<S: 'static> Predicate<S> for ContentTypeHeader {
|
||||
fn check(&self, req: &mut HttpRequest<S>) -> bool {
|
||||
fn check(&self, req: &Request, state: &S) -> bool {
|
||||
req.headers().contains_key(http::header::CONTENT_TYPE)
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
use actix_web::{App, HttpRequest, HttpResponse};
|
||||
|
||||
// <prefix>
|
||||
fn show_users(req: HttpRequest) -> HttpResponse {
|
||||
fn show_users(req: &HttpRequest) -> HttpResponse {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
// <resource>
|
||||
use actix_web::{http::Method, App, HttpRequest, HttpResponse};
|
||||
|
||||
fn index(req: HttpRequest) -> HttpResponse {
|
||||
fn index(req: &HttpRequest) -> HttpResponse {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
|
@ -1,22 +1,22 @@
|
||||
#![allow(dead_code)]
|
||||
use actix_web::{http::Method, App, HttpRequest};
|
||||
|
||||
fn get_projects(_: HttpRequest) -> String {
|
||||
fn get_projects(_: &HttpRequest) -> String {
|
||||
unimplemented!()
|
||||
}
|
||||
fn create_project(_: HttpRequest) -> String {
|
||||
fn create_project(_: &HttpRequest) -> String {
|
||||
unimplemented!()
|
||||
}
|
||||
fn update_project(_: HttpRequest) -> String {
|
||||
unimplemented!()
|
||||
}
|
||||
fn delete_project(_: HttpRequest) -> String {
|
||||
fn delete_project(_: &HttpRequest) -> String {
|
||||
unimplemented!()
|
||||
}
|
||||
fn get_tasks(_: HttpRequest) -> String {
|
||||
fn get_tasks(_: &HttpRequest) -> String {
|
||||
unimplemented!()
|
||||
}
|
||||
fn create_task(_: HttpRequest) -> String {
|
||||
fn create_task(_: &HttpRequest) -> String {
|
||||
unimplemented!()
|
||||
}
|
||||
fn update_task(_: HttpRequest) -> String {
|
||||
|
@ -1,7 +1,7 @@
|
||||
// <ext>
|
||||
use actix_web::{App, Error, HttpRequest, HttpResponse};
|
||||
|
||||
fn index(mut req: HttpRequest) -> Result<HttpResponse, Error> {
|
||||
fn index(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())
|
||||
|
Loading…
x
Reference in New Issue
Block a user