Skip to content

Commit

Permalink
Merge branch 'master' into update-derive-more
Browse files Browse the repository at this point in the history
  • Loading branch information
robjtede authored Aug 18, 2024
2 parents 757ff57 + 78ac5cf commit b874db5
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 14 deletions.
4 changes: 2 additions & 2 deletions actix-http/examples/actix-web.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use actix_http::HttpService;
use actix_server::Server;
use actix_service::map_config;
use actix_web::{dev::AppConfig, get, App};
use actix_web::{dev::AppConfig, get, App, Responder};

#[get("/")]
async fn index() -> &'static str {
async fn index() -> impl Responder {
"Hello, world. From Actix Web!"
}

Expand Down
5 changes: 2 additions & 3 deletions actix-http/examples/echo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,15 @@ async fn main() -> io::Result<()> {
body.extend_from_slice(&item?);
}

info!("request body: {:?}", body);
info!("request body: {body:?}");

let res = Response::build(StatusCode::OK)
.insert_header(("x-head", HeaderValue::from_static("dummy value!")))
.body(body);

Ok::<_, Error>(res)
})
// No TLS
.tcp()
.tcp() // No TLS
})?
.run()
.await
Expand Down
2 changes: 1 addition & 1 deletion actix-http/examples/hello-world.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ async fn main() -> io::Result<()> {
ext.insert(42u32);
})
.finish(|req: Request| async move {
info!("{:?}", req);
info!("{req:?}");

let mut res = Response::build(StatusCode::OK);
res.insert_header(("x-head", HeaderValue::from_static("dummy value!")));
Expand Down
6 changes: 3 additions & 3 deletions actix-http/examples/streaming-error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@ async fn main() -> io::Result<()> {
.bind("streaming-error", ("127.0.0.1", 8080), || {
HttpService::build()
.finish(|req| async move {
info!("{:?}", req);
info!("{req:?}");
let res = Response::ok();

Ok::<_, Infallible>(res.set_body(BodyStream::new(stream! {
yield Ok(Bytes::from("123"));
yield Ok(Bytes::from("456"));

actix_rt::time::sleep(Duration::from_millis(1000)).await;
actix_rt::time::sleep(Duration::from_secs(1)).await;

yield Err(io::Error::new(io::ErrorKind::Other, ""));
yield Err(io::Error::new(io::ErrorKind::Other, "abc"));
})))
})
.tcp()
Expand Down
7 changes: 3 additions & 4 deletions actix-http/examples/ws.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ use bytes::{Bytes, BytesMut};
use bytestring::ByteString;
use futures_core::{ready, Stream};
use tokio_util::codec::Encoder;
use tracing::{info, trace};

#[actix_rt::main]
async fn main() -> io::Result<()> {
Expand All @@ -37,12 +36,12 @@ async fn main() -> io::Result<()> {
}

async fn handler(req: Request) -> Result<Response<BodyStream<Heartbeat>>, Error> {
info!("handshaking");
tracing::info!("handshaking");
let mut res = ws::handshake(req.head())?;

// handshake will always fail under HTTP/2

info!("responding");
tracing::info!("responding");
res.message_body(BodyStream::new(Heartbeat::new(ws::Codec::new())))
}

Expand All @@ -64,7 +63,7 @@ impl Stream for Heartbeat {
type Item = Result<Bytes, Error>;

fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
trace!("poll");
tracing::trace!("poll");

ready!(self.as_mut().interval.poll_tick(cx));

Expand Down
3 changes: 2 additions & 1 deletion actix-web/src/test/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Various helpers for Actix applications to use during testing.
//!
//! # Creating A Test Service
//! # Initializing A Test Service
//! - [`init_service`]
//!
//! # Off-The-Shelf Test Services
Expand Down Expand Up @@ -49,6 +49,7 @@ pub use self::{
/// Must be used inside an async test. Works for both `ServiceRequest` and `HttpRequest`.
///
/// # Examples
///
/// ```
/// use actix_web::{http::StatusCode, HttpResponse};
///
Expand Down

0 comments on commit b874db5

Please sign in to comment.