mirror of
https://github.com/actix/actix-website
synced 2024-11-27 18:12:57 +01:00
c2f760dbbe
* chore(deps): bump derive_more from 0.99.18 to 1.0.0 in /examples Bumps [derive_more](https://github.com/JelteF/derive_more) from 0.99.18 to 1.0.0. - [Release notes](https://github.com/JelteF/derive_more/releases) - [Changelog](https://github.com/JelteF/derive_more/blob/master/CHANGELOG.md) - [Commits](https://github.com/JelteF/derive_more/compare/v0.99.18...v1.0.0) --- updated-dependencies: - dependency-name: derive_more dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> * chore: upgrade derive_more calls * ci: fix just invocation --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Rob Ede <robjtede@icloud.com>
34 lines
761 B
Rust
34 lines
761 B
Rust
pub mod helpers;
|
|
pub mod logging;
|
|
pub mod override_error;
|
|
pub mod recommend_one;
|
|
pub mod recommend_two;
|
|
|
|
// <response-error>
|
|
use actix_web::{error, Result};
|
|
use derive_more::derive::{Display, Error};
|
|
|
|
#[derive(Debug, Display, Error)]
|
|
#[display("my error: {name}")]
|
|
struct MyError {
|
|
name: &'static str,
|
|
}
|
|
|
|
// Use default implementation for `error_response()` method
|
|
impl error::ResponseError for MyError {}
|
|
|
|
async fn index() -> Result<&'static str, MyError> {
|
|
Err(MyError { name: "test" })
|
|
}
|
|
// </response-error>
|
|
|
|
#[actix_web::main]
|
|
async fn main() -> std::io::Result<()> {
|
|
use actix_web::{web, App, HttpServer};
|
|
|
|
HttpServer::new(|| App::new().route("/", web::get().to(index)))
|
|
.bind(("127.0.0.1", 8080))?
|
|
.run()
|
|
.await
|
|
}
|