mirror of
https://github.com/actix/actix-web.git
synced 2024-05-19 16:58:14 +00:00
Compare commits
6 commits
67ecf5ef64
...
b550a93d69
Author | SHA1 | Date | |
---|---|---|---|
b550a93d69 | |||
ba7fd048b6 | |||
d98938b125 | |||
5a5486b484 | |||
76b2b2734b | |||
98c99f3bc2 |
6
.github/workflows/ci-post-merge.yml
vendored
6
.github/workflows/ci-post-merge.yml
vendored
|
@ -45,7 +45,7 @@ jobs:
|
||||||
toolchain: ${{ matrix.version.version }}
|
toolchain: ${{ matrix.version.version }}
|
||||||
|
|
||||||
- name: Install cargo-hack and cargo-ci-cache-clean
|
- name: Install cargo-hack and cargo-ci-cache-clean
|
||||||
uses: taiki-e/install-action@v2.32.0
|
uses: taiki-e/install-action@v2.32.17
|
||||||
with:
|
with:
|
||||||
tool: cargo-hack,cargo-ci-cache-clean
|
tool: cargo-hack,cargo-ci-cache-clean
|
||||||
|
|
||||||
|
@ -88,7 +88,7 @@ jobs:
|
||||||
uses: actions-rust-lang/setup-rust-toolchain@v1.8.0
|
uses: actions-rust-lang/setup-rust-toolchain@v1.8.0
|
||||||
|
|
||||||
- name: Install cargo-hack
|
- name: Install cargo-hack
|
||||||
uses: taiki-e/install-action@v2.32.0
|
uses: taiki-e/install-action@v2.32.17
|
||||||
with:
|
with:
|
||||||
tool: cargo-hack
|
tool: cargo-hack
|
||||||
|
|
||||||
|
@ -109,7 +109,7 @@ jobs:
|
||||||
uses: actions-rust-lang/setup-rust-toolchain@v1.8.0
|
uses: actions-rust-lang/setup-rust-toolchain@v1.8.0
|
||||||
|
|
||||||
- name: Install nextest
|
- name: Install nextest
|
||||||
uses: taiki-e/install-action@v2.32.0
|
uses: taiki-e/install-action@v2.32.17
|
||||||
with:
|
with:
|
||||||
tool: nextest
|
tool: nextest
|
||||||
|
|
||||||
|
|
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
|
@ -50,7 +50,7 @@ jobs:
|
||||||
toolchain: ${{ matrix.version.version }}
|
toolchain: ${{ matrix.version.version }}
|
||||||
|
|
||||||
- name: Install cargo-hack and cargo-ci-cache-clean
|
- name: Install cargo-hack and cargo-ci-cache-clean
|
||||||
uses: taiki-e/install-action@v2.32.0
|
uses: taiki-e/install-action@v2.32.17
|
||||||
with:
|
with:
|
||||||
tool: cargo-hack,cargo-ci-cache-clean
|
tool: cargo-hack,cargo-ci-cache-clean
|
||||||
|
|
||||||
|
|
4
.github/workflows/coverage.yml
vendored
4
.github/workflows/coverage.yml
vendored
|
@ -23,7 +23,7 @@ jobs:
|
||||||
components: llvm-tools-preview
|
components: llvm-tools-preview
|
||||||
|
|
||||||
- name: Install cargo-llvm-cov
|
- name: Install cargo-llvm-cov
|
||||||
uses: taiki-e/install-action@v2.32.0
|
uses: taiki-e/install-action@v2.32.17
|
||||||
with:
|
with:
|
||||||
tool: cargo-llvm-cov
|
tool: cargo-llvm-cov
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ jobs:
|
||||||
run: cargo llvm-cov --workspace --all-features --codecov --output-path codecov.json
|
run: cargo llvm-cov --workspace --all-features --codecov --output-path codecov.json
|
||||||
|
|
||||||
- name: Upload coverage to Codecov
|
- name: Upload coverage to Codecov
|
||||||
uses: codecov/codecov-action@v4.1.1
|
uses: codecov/codecov-action@v4.3.0
|
||||||
with:
|
with:
|
||||||
files: codecov.json
|
files: codecov.json
|
||||||
fail_ci_if_error: true
|
fail_ci_if_error: true
|
||||||
|
|
2
.github/workflows/lint.yml
vendored
2
.github/workflows/lint.yml
vendored
|
@ -82,7 +82,7 @@ jobs:
|
||||||
toolchain: nightly-2023-08-25
|
toolchain: nightly-2023-08-25
|
||||||
|
|
||||||
- name: Install cargo-public-api
|
- name: Install cargo-public-api
|
||||||
uses: taiki-e/install-action@v2.32.0
|
uses: taiki-e/install-action@v2.32.17
|
||||||
with:
|
with:
|
||||||
tool: cargo-public-api
|
tool: cargo-public-api
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ use crate::{HttpResponse, ResponseError};
|
||||||
|
|
||||||
/// General purpose Actix Web error.
|
/// General purpose Actix Web error.
|
||||||
///
|
///
|
||||||
/// An Actix Web error is used to carry errors from `std::error` through actix in a convenient way.
|
/// An Actix Web error is used to carry errors from `std::error` through Actix in a convenient way.
|
||||||
/// It can be created through converting errors with `into()`.
|
/// It can be created through converting errors with `into()`.
|
||||||
///
|
///
|
||||||
/// Whenever it is created from an external object a response error is created for it that can be
|
/// Whenever it is created from an external object a response error is created for it that can be
|
||||||
|
@ -14,6 +14,7 @@ use crate::{HttpResponse, ResponseError};
|
||||||
/// you can always get a `ResponseError` reference from it.
|
/// you can always get a `ResponseError` reference from it.
|
||||||
pub struct Error {
|
pub struct Error {
|
||||||
cause: Box<dyn ResponseError>,
|
cause: Box<dyn ResponseError>,
|
||||||
|
response_mappers: Vec<Box<dyn Fn(HttpResponse) -> HttpResponse>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Error {
|
impl Error {
|
||||||
|
@ -29,7 +30,20 @@ impl Error {
|
||||||
|
|
||||||
/// Shortcut for creating an `HttpResponse`.
|
/// Shortcut for creating an `HttpResponse`.
|
||||||
pub fn error_response(&self) -> HttpResponse {
|
pub fn error_response(&self) -> HttpResponse {
|
||||||
self.cause.error_response()
|
let mut res = self.cause.error_response();
|
||||||
|
|
||||||
|
for mapper in &self.response_mappers {
|
||||||
|
res = (mapper)(res);
|
||||||
|
}
|
||||||
|
|
||||||
|
res
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn add_mapper<F, B>(&mut self, mapper: F)
|
||||||
|
where
|
||||||
|
F: Fn(HttpResponse) -> HttpResponse + 'static,
|
||||||
|
{
|
||||||
|
self.response_mappers.push(Box::new(mapper))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,6 +70,7 @@ impl<T: ResponseError + 'static> From<T> for Error {
|
||||||
fn from(err: T) -> Error {
|
fn from(err: T) -> Error {
|
||||||
Error {
|
Error {
|
||||||
cause: Box::new(err),
|
cause: Box::new(err),
|
||||||
|
response_mappers: Vec::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue