Skip to content

Commit

Permalink
prepare 0.2 release.
Browse files Browse the repository at this point in the history
  • Loading branch information
fakeshadow committed Jan 19, 2024
1 parent 94b302e commit aaa73d8
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 32 deletions.
1 change: 0 additions & 1 deletion web/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ http-body = { version = "1", optional = true }

[dev-dependencies]
xitca-codegen = { version = "0.1" }
xitca-web = { version = "0.2", features = ["codegen", "json", "tower-http-compat"] }

futures-util = { version = "0.3", features = ["alloc"] }
serde = { version = "1.0.137", features = ["derive"] }
Expand Down
68 changes: 37 additions & 31 deletions web/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
//! a web framework focus on memory efficiency, composability, and fast compile time.
//!
//! # Quick start
//! ```rust
//! ```no_run
//! use xitca_web::{handler::handler_service, route::get, App};
//!
//! # fn _main() -> std::io::Result<()> {
//! App::new()
//! .at("/", get(handler_service(|| async { "Hello,World!" })))
//! .serve()
//! .bind("localhost:8080")?
//! .run()
//! .wait()
//! # }
//! fn main() -> std::io::Result<()> {
//! App::new()
//! .at("/", get(handler_service(|| async { "Hello,World!" })))
//! .serve()
//! .bind("localhost:8080")?
//! .run()
//! .wait()
//! }
//! ```
//!
//! # Memory efficient
Expand All @@ -20,27 +20,15 @@
//!
//! ## Zero copy
//! ```rust
//! # #[cfg(feature = "json")]
//! # fn _main() -> std::io::Result<()> {
//! use xitca_web::{
//! error::Error,
//! handler::{handler_service, json::LazyJson, path::PathRef},
//! route::{get, post},
//! App
//! };
//!
//! # fn _main() -> std::io::Result<()> {
//! // Almost all magic extract types in xitca-web utilize zero copy
//! // to avoid unnecessary memory copy.
//! App::new()
//! // a route handling incoming url query.
//! .at("/query", get(handler_service(url_query)))
//! // a route handling incoming json object.
//! .at("/json", post(handler_service(json)))
//! .serve()
//! .bind("localhost:8080")?
//! .run()
//! .wait()
//! # }
//!
//! // PathRef is able to borrow http request's path string as reference
//! // without copying it.
//! async fn url_query(PathRef(path): PathRef<'_>) -> &'static str {
Expand All @@ -60,6 +48,19 @@
//! println!("{name}");
//! Ok("zero copy json")
//! }
//!
//! // Almost all magic extract types in xitca-web utilize zero copy
//! // to avoid unnecessary memory copy.
//! App::new()
//! // a route handling incoming url query.
//! .at("/query", get(handler_service(url_query)))
//! // a route handling incoming json object.
//! .at("/json", post(handler_service(json)))
//! .serve()
//! .bind("localhost:8080")?
//! .run()
//! .wait()
//! # }
//! ```
//!
//! ## Zero cost
Expand Down Expand Up @@ -113,6 +114,7 @@
//! service::fn_service,
//! App, WebContext
//! };
//!
//! # fn _main() -> std::io::Result<()> {
//! App::new()
//! // high level abstraction. see fn high for detail.
Expand Down Expand Up @@ -175,6 +177,7 @@
//! service::{Service, ServiceExt},
//! App, WebContext
//! };
//!
//! # fn _main() -> std::io::Result<()> {
//! // ServiceExt::enclosed_fn combinator enables async function as middleware.
//! // in xitca_web almost all service can be enclosed by an middleware.
Expand Down Expand Up @@ -207,14 +210,16 @@
//! For more detailed middleware documentation please reference [middleware]
//!
//! ## Cross crates integration
//! use tower-http inside xitca-web application.
//! ```rust
//! # #[cfg(feature = "tower-http-compat")]
//! # fn _main() -> std::io::Result<()> {
//! use tower_http::services::ServeDir;
//! use xitca_web::{
//! service::tower_http_compat::TowerHttpCompat,
//! App
//! };
//! # fn _main() -> std::io::Result<()> {
//! // use tower-http inside xitca-web application.
//!
//! App::new()
//! .at("/", TowerHttpCompat::new(ServeDir::new("/some_folder")))
//! .serve()
Expand All @@ -229,12 +234,12 @@
//! - light weight dependency tree
//!
//! ## opt-in proc macro
//! ```no_run
//! // in xitca-web proc macro is opt-in. This result in a fast compile time with zero
//! // public proc macro. That said you still can enable macros for a higher level style
//! // of API.
//!
//! // enable "codegen" cargo feature for xitca_web
//! in xitca-web proc macro is opt-in. This result in a fast compile time with zero
//! public proc macro. That said you still can enable macros for a higher level style
//! of API.
//! ```rust
//! # #[cfg(feature = "codegen")]
//! # fn _main() {
//! use xitca_web::{codegen::route, App};
//!
//! #[tokio::main]
Expand All @@ -251,6 +256,7 @@
//! async fn index() -> &'static str {
//! "Hello,World!"
//! }
//! # }
//! ```
#![forbid(unsafe_code)]
Expand Down

0 comments on commit aaa73d8

Please sign in to comment.