1
0
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:
Nikolay Kim 2018-07-21 05:21:41 -07:00
parent 324799dd2a
commit 5cd8d2edc8
17 changed files with 28 additions and 28 deletions

View File

@ -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"

View File

@ -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!"
}

View File

@ -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

View File

@ -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"

View File

@ -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>

View File

@ -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"

View File

@ -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!"
}

View File

@ -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"

View File

@ -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))

View File

@ -10,6 +10,6 @@ fn main() {
// </norm>
use actix_web::HttpRequest;
fn index(req: HttpRequest) -> String {
fn index(req: &HttpRequest) -> String {
unimplemented!()
}

View File

@ -11,6 +11,6 @@ fn main() {
use actix_web::HttpRequest;
fn index(req: HttpRequest) -> String {
fn index(req: &HttpRequest) -> String {
unimplemented!()
}

View File

@ -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))
}

View File

@ -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)
}
}

View File

@ -1,7 +1,7 @@
use actix_web::{App, HttpRequest, HttpResponse};
// <prefix>
fn show_users(req: HttpRequest) -> HttpResponse {
fn show_users(req: &HttpRequest) -> HttpResponse {
unimplemented!()
}

View File

@ -1,7 +1,7 @@
// <resource>
use actix_web::{http::Method, App, HttpRequest, HttpResponse};
fn index(req: HttpRequest) -> HttpResponse {
fn index(req: &HttpRequest) -> HttpResponse {
unimplemented!()
}

View File

@ -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 {

View File

@ -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())