mirror of
https://github.com/fafhrd91/actix-web
synced 2025-07-04 01:51:30 +02:00
Compare commits
4 Commits
web-v2.0.0
...
files-v0.2
Author | SHA1 | Date | |
---|---|---|---|
f45db1f909 | |||
3751a4018e | |||
0cb1b0642f | |||
48476362a3 |
67
.github/workflows/main.yml
vendored
Normal file
67
.github/workflows/main.yml
vendored
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
name: CI
|
||||||
|
|
||||||
|
on: [push, pull_request]
|
||||||
|
|
||||||
|
env:
|
||||||
|
VCPKGRS_DYNAMIC: 1
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build_and_test:
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
toolchain:
|
||||||
|
- x86_64-pc-windows-msvc
|
||||||
|
# - i686-pc-windows-msvc
|
||||||
|
- x86_64-apple-darwin
|
||||||
|
version:
|
||||||
|
- stable
|
||||||
|
- nightly
|
||||||
|
include:
|
||||||
|
- toolchain: x86_64-pc-windows-msvc
|
||||||
|
os: windows-latest
|
||||||
|
arch: x64
|
||||||
|
# - toolchain: i686-pc-windows-msvc
|
||||||
|
# os: windows-latest
|
||||||
|
# arch: x86
|
||||||
|
- toolchain: x86_64-apple-darwin
|
||||||
|
os: macOS-latest
|
||||||
|
|
||||||
|
name: ${{ matrix.version }} - ${{ matrix.toolchain }}
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@master
|
||||||
|
|
||||||
|
- name: Install ${{ matrix.version }}
|
||||||
|
uses: actions-rs/toolchain@v1
|
||||||
|
with:
|
||||||
|
toolchain: ${{ matrix.version }}-${{ matrix.toolchain }}
|
||||||
|
default: true
|
||||||
|
|
||||||
|
- name: Install OpenSSL
|
||||||
|
if: matrix.os == 'windows-latest'
|
||||||
|
run: |
|
||||||
|
vcpkg integrate install
|
||||||
|
vcpkg install openssl:${{ matrix.arch }}-windows
|
||||||
|
|
||||||
|
- name: check nightly
|
||||||
|
if: matrix.version == 'nightly'
|
||||||
|
uses: actions-rs/cargo@v1
|
||||||
|
with:
|
||||||
|
command: check
|
||||||
|
args: --all --benches --bins --examples --tests
|
||||||
|
|
||||||
|
- name: check stable
|
||||||
|
if: matrix.version == 'stable'
|
||||||
|
uses: actions-rs/cargo@v1
|
||||||
|
with:
|
||||||
|
command: check
|
||||||
|
args: --all --bins --examples --tests
|
||||||
|
|
||||||
|
- name: tests
|
||||||
|
if: matrix.toolchain != 'x86_64-pc-windows-gnu'
|
||||||
|
uses: actions-rs/cargo@v1
|
||||||
|
with:
|
||||||
|
command: test
|
||||||
|
args: --all --all-features -- --nocapture
|
@ -1,5 +1,9 @@
|
|||||||
# Changes
|
# Changes
|
||||||
|
|
||||||
|
## [0.2.0] - 2019-12-20
|
||||||
|
|
||||||
|
* Release
|
||||||
|
|
||||||
## [0.2.0-alpha.3] - 2019-12-07
|
## [0.2.0-alpha.3] - 2019-12-07
|
||||||
|
|
||||||
* Migrate to actix-web 2.0.0
|
* Migrate to actix-web 2.0.0
|
||||||
|
@ -1,6 +1,10 @@
|
|||||||
# Changes
|
# Changes
|
||||||
|
|
||||||
## [0.2.0] - 2019-12-xx
|
## [0.2.1] - 2019-12-22
|
||||||
|
|
||||||
|
* Use the same format for file URLs regardless of platforms
|
||||||
|
|
||||||
|
## [0.2.0] - 2019-12-20
|
||||||
|
|
||||||
* Fix BodyEncoding trait import #1220
|
* Fix BodyEncoding trait import #1220
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "actix-files"
|
name = "actix-files"
|
||||||
version = "0.2.0"
|
version = "0.2.1"
|
||||||
authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
|
authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
|
||||||
description = "Static files support for actix web."
|
description = "Static files support for actix web."
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
|
@ -155,7 +155,7 @@ impl Directory {
|
|||||||
// show file url as relative to static path
|
// show file url as relative to static path
|
||||||
macro_rules! encode_file_url {
|
macro_rules! encode_file_url {
|
||||||
($path:ident) => {
|
($path:ident) => {
|
||||||
utf8_percent_encode(&$path.to_string_lossy(), CONTROLS)
|
utf8_percent_encode(&$path, CONTROLS)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -178,7 +178,8 @@ fn directory_listing(
|
|||||||
if dir.is_visible(&entry) {
|
if dir.is_visible(&entry) {
|
||||||
let entry = entry.unwrap();
|
let entry = entry.unwrap();
|
||||||
let p = match entry.path().strip_prefix(&dir.path) {
|
let p = match entry.path().strip_prefix(&dir.path) {
|
||||||
Ok(p) => base.join(p),
|
Ok(p) if cfg!(windows) => base.join(p).to_string_lossy().replace("\\", "/"),
|
||||||
|
Ok(p) => base.join(p).to_string_lossy().into_owned(),
|
||||||
Err(_) => continue,
|
Err(_) => continue,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
# Changes
|
# Changes
|
||||||
|
|
||||||
|
## [0.2.0] - 2019-12-20
|
||||||
|
|
||||||
|
* Use actix-web 2.0
|
||||||
|
|
||||||
## [0.1.0] - 2019-06-xx
|
## [0.1.0] - 2019-06-xx
|
||||||
|
|
||||||
* Move identity middleware to separate crate
|
* Move identity middleware to separate crate
|
||||||
|
@ -1,6 +1,10 @@
|
|||||||
# Changes
|
# Changes
|
||||||
|
|
||||||
## [2.0.0-alpha.4] - 2019-12-xx
|
## [0.2.0] - 2019-12-20
|
||||||
|
|
||||||
|
* Release
|
||||||
|
|
||||||
|
## [0.2.0-alpha.4] - 2019-12-xx
|
||||||
|
|
||||||
* Multipart handling now handles Pending during read of boundary #1205
|
* Multipart handling now handles Pending during read of boundary #1205
|
||||||
|
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
# Changes
|
# Changes
|
||||||
|
|
||||||
|
## [0.3.0] - 2019-12-20
|
||||||
|
|
||||||
|
* Release
|
||||||
|
|
||||||
## [0.3.0-alpha.4] - 2019-12-xx
|
## [0.3.0-alpha.4] - 2019-12-xx
|
||||||
|
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
# Changes
|
# Changes
|
||||||
|
|
||||||
|
## [2.0.0] - 2019-12-20
|
||||||
|
|
||||||
|
* Release
|
||||||
|
|
||||||
## [2.0.0-alpha.1] - 2019-12-15
|
## [2.0.0-alpha.1] - 2019-12-15
|
||||||
|
|
||||||
* Migrate to actix-web 2.0.0
|
* Migrate to actix-web 2.0.0
|
||||||
|
@ -3,16 +3,22 @@ use std::sync::{Arc, Mutex};
|
|||||||
use std::{fmt, io, net};
|
use std::{fmt, io, net};
|
||||||
|
|
||||||
use actix_http::{
|
use actix_http::{
|
||||||
body::MessageBody, Error, HttpService, KeepAlive, Protocol, Request, Response,
|
body::MessageBody, Error, HttpService, KeepAlive, Request, Response,
|
||||||
};
|
};
|
||||||
use actix_server::{Server, ServerBuilder};
|
use actix_server::{Server, ServerBuilder};
|
||||||
use actix_service::{
|
use actix_service::{
|
||||||
map_config, pipeline_factory, IntoServiceFactory, Service, ServiceFactory,
|
map_config, IntoServiceFactory, Service, ServiceFactory,
|
||||||
};
|
};
|
||||||
use futures::future::ok;
|
|
||||||
|
|
||||||
use net2::TcpBuilder;
|
use net2::TcpBuilder;
|
||||||
|
|
||||||
|
#[cfg(unix)]
|
||||||
|
use actix_http::Protocol;
|
||||||
|
#[cfg(unix)]
|
||||||
|
use actix_service::pipeline_factory;
|
||||||
|
#[cfg(unix)]
|
||||||
|
use futures::future::ok;
|
||||||
|
|
||||||
#[cfg(feature = "openssl")]
|
#[cfg(feature = "openssl")]
|
||||||
use actix_tls::openssl::{AlpnError, SslAcceptor, SslAcceptorBuilder};
|
use actix_tls::openssl::{AlpnError, SslAcceptor, SslAcceptorBuilder};
|
||||||
#[cfg(feature = "rustls")]
|
#[cfg(feature = "rustls")]
|
||||||
|
23
src/test.rs
23
src/test.rs
@ -66,7 +66,7 @@ pub fn default_service(
|
|||||||
/// let mut app = test::init_service(
|
/// let mut app = test::init_service(
|
||||||
/// App::new()
|
/// App::new()
|
||||||
/// .service(web::resource("/test").to(|| async { HttpResponse::Ok() }))
|
/// .service(web::resource("/test").to(|| async { HttpResponse::Ok() }))
|
||||||
/// );
|
/// ).await;
|
||||||
///
|
///
|
||||||
/// // Create request object
|
/// // Create request object
|
||||||
/// let req = test::TestRequest::with_uri("/test").to_request();
|
/// let req = test::TestRequest::with_uri("/test").to_request();
|
||||||
@ -962,7 +962,7 @@ mod tests {
|
|||||||
use std::time::SystemTime;
|
use std::time::SystemTime;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::{http::header, web, App, HttpResponse};
|
use crate::{http::header, web, App, HttpResponse, Responder};
|
||||||
|
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
async fn test_basics() {
|
async fn test_basics() {
|
||||||
@ -1148,6 +1148,25 @@ mod tests {
|
|||||||
assert!(res.status().is_success());
|
assert!(res.status().is_success());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[actix_rt::test]
|
||||||
|
async fn test_server_data() {
|
||||||
|
async fn handler(data: web::Data<usize>) -> impl Responder {
|
||||||
|
assert_eq!(**data, 10);
|
||||||
|
HttpResponse::Ok()
|
||||||
|
}
|
||||||
|
|
||||||
|
let mut app = init_service(
|
||||||
|
App::new()
|
||||||
|
.data(10usize)
|
||||||
|
.service(web::resource("/index.html").to(handler)),
|
||||||
|
)
|
||||||
|
.await;
|
||||||
|
|
||||||
|
let req = TestRequest::post().uri("/index.html").to_request();
|
||||||
|
let res = app.call(req).await.unwrap();
|
||||||
|
assert!(res.status().is_success());
|
||||||
|
}
|
||||||
|
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
async fn test_actor() {
|
async fn test_actor() {
|
||||||
use actix::Actor;
|
use actix::Actor;
|
||||||
|
Reference in New Issue
Block a user