1
0
Fork 0
mirror of https://github.com/actix/actix-web.git synced 2024-11-25 02:51:15 +00:00

docs(web): unmention try_init_service

This commit is contained in:
Rob Ede 2024-08-18 14:33:28 +01:00
parent 4303dd8c37
commit 78ac5cf482
No known key found for this signature in database
GPG key ID: 97C636207D3EF933
6 changed files with 11 additions and 14 deletions

View file

@ -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!"
}

View file

@ -23,7 +23,7 @@ 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!")))
@ -31,8 +31,7 @@ async fn main() -> io::Result<()> {
Ok::<_, Error>(res)
})
// No TLS
.tcp()
.tcp() // No TLS
})?
.run()
.await

View file

@ -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!")));

View file

@ -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()

View file

@ -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<()> {
@ -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())))
}
@ -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));

View file

@ -2,7 +2,6 @@
//!
//! # Initializing A Test Service
//! - [`init_service`]
//! - [`try_init_service`]
//!
//! # Off-The-Shelf Test Services
//! - [`ok_service`]