mirror of
https://github.com/actix/examples
synced 2025-06-26 17:17:42 +02:00
Actix Web
This commit is contained in:
@ -84,7 +84,7 @@ async fn main() -> io::Result<()> {
|
||||
.wrap(middleware::Compress::default())
|
||||
// cookie session middleware
|
||||
.wrap(CookieSession::signed(&[0; 32]).secure(false))
|
||||
// enable logger - always register actix-web Logger middleware last
|
||||
// enable logger - always register Actix Web Logger middleware last
|
||||
.wrap(middleware::Logger::default())
|
||||
// register favicon
|
||||
.service(favicon)
|
||||
|
@ -1 +1 @@
|
||||
This project illustrates custom error propagation through futures in actix-web
|
||||
This project illustrates custom error propagation through futures in Actix Web.
|
||||
|
@ -1,4 +1,4 @@
|
||||
This is a contrived example intended to illustrate a few important actix-web features.
|
||||
This is a contrived example intended to illustrate a few important Actix Web features.
|
||||
|
||||
*Imagine* that you have a process that involves 3 steps. The steps here
|
||||
are dumb in that they do nothing other than call an HTTP endpoint that
|
||||
@ -10,7 +10,7 @@ Actix Web features illustrated here include:
|
||||
|
||||
1. handling json input param
|
||||
2. validating user-submitted parameters using the 'validator' crate
|
||||
2. actix-web client features:
|
||||
2. `awc` client features:
|
||||
- POSTing json body
|
||||
3. chaining futures into a single response used by an asynch endpoint
|
||||
|
||||
|
@ -1,14 +1,14 @@
|
||||
// This is a contrived example intended to illustrate actix-web features.
|
||||
// This is a contrived example intended to illustrate Actix Web features.
|
||||
// *Imagine* that you have a process that involves 3 steps. The steps here
|
||||
// are dumb in that they do nothing other than call an
|
||||
// httpbin endpoint that returns the json that was posted to it. The intent
|
||||
// here is to illustrate how to chain these steps together as futures and return
|
||||
// a final result in a response.
|
||||
//
|
||||
// Actix-web features illustrated here include:
|
||||
// Actix Web features illustrated here include:
|
||||
// 1. handling json input param
|
||||
// 2. validating user-submitted parameters using the 'validator' crate
|
||||
// 2. actix-web client features:
|
||||
// 2. `awc` client features:
|
||||
// - POSTing json body
|
||||
// 3. chaining futures into a single response used by an async endpoint
|
||||
|
||||
|
@ -3,11 +3,9 @@
|
||||
Demonstrates how to shutdown the web server in a couple of ways:
|
||||
|
||||
1. remotely, via http request
|
||||
- Created in response to actix/actix-web#1315
|
||||
|
||||
2. sending a SIGINT signal to the server (control-c)
|
||||
- actix-server natively supports SIGINT
|
||||
|
||||
- Created in response to actix/actix-web#1315
|
||||
1. sending a SIGINT signal to the server (control-c)
|
||||
- actix-server natively supports SIGINT
|
||||
|
||||
## Usage
|
||||
|
||||
@ -24,6 +22,6 @@ cargo run --bin shutdown-server
|
||||
### Available Routes
|
||||
|
||||
- [GET /hello](http://localhost:8080/hello)
|
||||
- Regular hello world route
|
||||
- Regular hello world route
|
||||
- [POST /stop](http://localhost:8080/stop)
|
||||
- Calling this will shutdown the server and exit
|
||||
- Calling this will shutdown the server and exit
|
||||
|
@ -10,7 +10,7 @@
|
||||
//!
|
||||
//! We retrieve our app state within our handlers with a `state: Data<...>` argument.
|
||||
//!
|
||||
//! By default, `actix-web` runs one [`App`] per logical cpu core.
|
||||
//! By default, Actix Web runs one [`App`] per logical cpu core.
|
||||
//! When running on `<N>` cores, we see that the example will increment `counter_mutex` (global state via
|
||||
//! Mutex) and `counter_atomic` (global state via Atomic variable) each time the endpoint is called,
|
||||
//! but only appear to increment `counter_cell` every Nth time on average (thread-local state). This
|
||||
|
Reference in New Issue
Block a user