diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 06620891..79b4180b 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -15,10 +15,10 @@ Please fill in as much of the template below as you're able. ### Version ### Platform @@ -30,7 +30,7 @@ Output of `uname -a` (UNIX), or version and 32 or 64-bit (Windows) ### Crates diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 6f618620..97f2ce15 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -4,7 +4,7 @@ the requirements below. Bug fixes and new features should include tests. -Contributors guide: https://github.com/davidpdrsn/tower-web/blob/master/CONTRIBUTING.md +Contributors guide: https://github.com/davidpdrsn/awebframework/blob/master/CONTRIBUTING.md --> ## Motivation diff --git a/.github/workflows/patch.toml b/.github/workflows/patch.toml index 1aafd58e..d5c2be16 100644 --- a/.github/workflows/patch.toml +++ b/.github/workflows/patch.toml @@ -1,4 +1,4 @@ # Patch dependencies to run all tests against versions of the crate in the # repository. [patch.crates-io] -tower-web = { path = "tower-web" } +awebframework = { path = "awebframework" } diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 13ac872f..21de8076 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,9 +1,9 @@ -# Contributing to Tower HTTP +# Contributing to awebframework :balloon: Thanks for your help improving the project! We are so happy to have you! -There are opportunities to contribute to `tower-web` at any level. It doesn't +There are opportunities to contribute to `awebframework` at any level. It doesn't matter if you are just getting started with Rust or are the most weathered expert, we can use your help. @@ -12,7 +12,7 @@ expert, we can use your help. This guide will help you get started. **Do not let this guide intimidate you**. It should be considered a map to help you navigate the process. -Don't know where to start? Check [issues labeled with "E-help-wanted"](https://github.com/davidpdrsn/tower-web/issues?q=is%3Aopen+is%3Aissue+label%3AE-help-wanted) or ["E-easy"](https://github.com/davidpdrsn/tower-web/issues?q=is%3Aopen+is%3Aissue+label%3AE-easy). +Don't know where to start? Check [issues labeled with "E-help-wanted"](https://github.com/davidpdrsn/awebframework/issues?q=is%3Aopen+is%3Aissue+label%3AE-help-wanted) or ["E-easy"](https://github.com/davidpdrsn/awebframework/issues?q=is%3Aopen+is%3Aissue+label%3AE-easy). You may also get help with contributing in the [`tower` Discord channel][discord], please join us! @@ -21,7 +21,7 @@ channel][discord], please join us! ## Conduct -The `tower-web` project adheres to the [Rust Code of Conduct][coc]. This +The `awebframework` project adheres to the [Rust Code of Conduct][coc]. This describes the _minimum_ behavior expected from all contributors. [coc]: https://github.com/rust-lang/rust/blob/master/CODE_OF_CONDUCT.md @@ -31,8 +31,8 @@ describes the _minimum_ behavior expected from all contributors. For any issue, there are fundamentally three ways an individual can contribute: 1. By opening the issue for discussion: For instance, if you believe that you - have uncovered a bug in a `tower-web` crate, creating a new issue in the - davidpdrsn/tower-web [issue tracker][issues] is the way to report it. + have uncovered a bug in a `awebframework` crate, creating a new issue in the + davidpdrsn/awebframework [issue tracker][issues] is the way to report it. 2. By helping to triage the issue: This can be done by providing supporting details (a test case that demonstrates a bug), providing @@ -42,12 +42,12 @@ For any issue, there are fundamentally three ways an individual can contribute: 3. By helping to resolve the issue: Typically this is done either in the form of demonstrating that the issue reported is not a problem after all, or more often, by opening a Pull Request that changes some bit of something in - tower-web in a concrete and reviewable manner. + awebframework in a concrete and reviewable manner. **Anybody can participate in any stage of contribution**. We urge you to participate in the discussion around bugs and participate in reviewing PRs. -[issues]: https://github.com/davidpdrsn/tower-web/issues +[issues]: https://github.com/davidpdrsn/awebframework/issues ### Asking for General Help @@ -59,7 +59,7 @@ PR that helps others avoid the problems that you encountered. ### Submitting a Bug Report -When opening a new issue in the `tower-web` issue tracker, users will +When opening a new issue in the `awebframework` issue tracker, users will be presented with a [basic template][template] that should be filled in. If you believe that you have uncovered a bug, please fill out this form, following the template to the best of your ability. Do not worry if you cannot answer every @@ -104,7 +104,7 @@ workflow that ensures that the proposed changes meet the minimal quality. ## Pull Requests Pull Requests are the way concrete changes are made to the code, documentation, -and dependencies in the `tower-web` repository. +and dependencies in the `awebframework` repository. Even tiny pull requests (e.g., one character pull request fixing a typo in API documentation) are greatly appreciated. Before making a large change, it is @@ -225,8 +225,8 @@ perfect grammar, or exact style matches. Do not succumb to that temptation. Focus first on the most significant aspects of the change: -1. Does this change make sense for tower-web? -2. Does this change make tower-web better, even if only incrementally? +1. Does this change make sense for awebframework? +2. Does this change make awebframework better, even if only incrementally? 3. Are there clear bugs or larger scale issues that need attending to? 4. Is the commit message readable and correct? If it contains a breaking change is it clear enough? @@ -257,8 +257,8 @@ with the appropriate reason to keep the conversation flow concise and relevant. Be aware that *how* you communicate requests and reviews in your feedback can have a significant impact on the success of the Pull Request. Yes, we may land a -particular change that makes `tower-web` better, but the individual might just -not want to have anything to do with `tower-web` ever again. The goal is not +particular change that makes `awebframework` better, but the individual might just +not want to have anything to do with `awebframework` ever again. The goal is not just having good code. ### Abandoned or Stalled Pull Requests diff --git a/Cargo.toml b/Cargo.toml index 497056e6..27bf2e32 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,15 +1,15 @@ [package] authors = ["David Pedersen "] -categories = [] +categories = [] # TODO description = "Web framework that focuses on ergonomics and modularity" documentation = "https://docs.rs/tower-http/0.1.0" edition = "2018" -homepage = "https://github.com/davidpdrsn/tower-web" +homepage = "https://github.com/davidpdrsn/awebframework" keywords = ["http", "web", "framework"] license = "MIT" -name = "tower-web" +name = "awebframework" readme = "README.md" -repository = "https://github.com/davidpdrsn/tower-web" +repository = "https://github.com/davidpdrsn/awebframework" version = "0.1.0" [features] diff --git a/README.md b/README.md index 8dfbbbf8..bb7e5b6a 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,16 @@ -# tower-web +# awebframework -**WARNING:** tower-web is very much still work in progress. Nothing is released +**WARNING:** awebframework is very much still work in progress. Nothing is released to crates.io yet and you shouldn't be using this in production. -tower-web (name pending) is a tiny web application framework that focuses on +awebframework (name pending) is a tiny web application framework that focuses on ergonomics and modularity. -[![Build status](https://github.com/davidpdrsn/tower-web/workflows/CI/badge.svg)](https://github.com/davidpdrsn/tower-web/actions) +[![Build status](https://github.com/davidpdrsn/awebframework/workflows/CI/badge.svg)](https://github.com/davidpdrsn/awebframework/actions) More information about this crate can be found in the [crate documentation][docs]. @@ -19,17 +19,17 @@ More information about this crate can be found in the [crate documentation][docs - Ease of use. Building web apps in Rust should be as easy as `async fn handle(Request) -> Response`. -- Solid foundation. tower-web is built on top of tower and makes it easy to +- Solid foundation. awebframework is built on top of tower and makes it easy to plug in any middleware from the [tower] and [tower-http] ecosystem. - Focus on routing, extracting data from requests, and generating responses. Tower middleware can handle the rest. -- Macro free core. Macro frameworks have their place but tower-web focuses +- Macro free core. Macro frameworks have their place but awebframework focuses on providing a core that is macro free. ## Usage example ```rust -use tower_web::prelude::*; +use awebframework::prelude::*; use hyper::Server; use std::net::SocketAddr; use tower::make::Shared; @@ -50,21 +50,20 @@ async fn main() { ## Examples -The [examples] folder contains various examples of how to use tower-web. The +The [examples] folder contains various examples of how to use awebframework. The [docs] also have lots of examples ## Getting Help -If you're new to tower its [guides] might help. In the tower-web repo we also -have a [number of examples][examples] showing how to put everything together. -You're also welcome to ask in the [`#tower` Discord channel][chat] or open an -[issue] with your question. +In the awebframework's repo we also have a [number of examples][examples] +showing how to put everything together. You're also welcome to ask in the +[`#tower` Discord channel][chat] or open an [issue] with your question. ## Contributing :balloon: Thanks for your help improving the project! We are so happy to have you! We have a [contributing guide][guide] to help you get involved in the -tower-web project. +awebframework project. ## License @@ -73,13 +72,13 @@ This project is licensed under the [MIT license](LICENSE). ### Contribution Unless you explicitly state otherwise, any contribution intentionally submitted -for inclusion in tower-web by you, shall be licensed as MIT, without any +for inclusion in awebframework by you, shall be licensed as MIT, without any additional terms or conditions. -[examples]: https://github.com/davidpdrsn/tower-web/tree/master/examples +[examples]: https://github.com/davidpdrsn/awebframework/tree/master/examples [docs]: https://docs.rs/tower-http/0.1.0 [tower]: https://crates.io/crates/tower [tower-http]: https://crates.io/crates/tower-http [guide]: CONTRIBUTING.md [chat]: https://discord.gg/tokio -[issue]: https://github.com/davidpdrsn/tower-web/issues/new +[issue]: https://github.com/davidpdrsn/awebframework/issues/new diff --git a/examples/form.rs b/examples/form.rs index 4076b183..d4a70a8b 100644 --- a/examples/form.rs +++ b/examples/form.rs @@ -1,7 +1,7 @@ +use awebframework::prelude::*; use http::Request; use serde::Deserialize; use std::net::SocketAddr; -use tower_web::prelude::*; #[tokio::main] async fn main() { diff --git a/examples/hello_world.rs b/examples/hello_world.rs index 3d01ba59..6483c044 100644 --- a/examples/hello_world.rs +++ b/examples/hello_world.rs @@ -1,6 +1,6 @@ +use awebframework::prelude::*; use http::StatusCode; use std::net::SocketAddr; -use tower_web::prelude::*; #[tokio::main] async fn main() { diff --git a/examples/key_value_store.rs b/examples/key_value_store.rs index f74423a9..6dd16842 100644 --- a/examples/key_value_store.rs +++ b/examples/key_value_store.rs @@ -1,4 +1,4 @@ -//! Simple in-memory key/value store showing features of tower-web. +//! Simple in-memory key/value store showing features of awebframework. //! //! Run with: //! @@ -6,6 +6,12 @@ //! RUST_LOG=tower_http=debug,key_value_store=trace cargo run --example key_value_store //! ``` +use awebframework::{ + extract::{ContentLengthLimit, Extension, UrlParams}, + prelude::*, + response::IntoResponse, + routing::BoxRoute, +}; use bytes::Bytes; use http::StatusCode; use std::{ @@ -20,12 +26,6 @@ use tower_http::{ add_extension::AddExtensionLayer, auth::RequireAuthorizationLayer, compression::CompressionLayer, trace::TraceLayer, }; -use tower_web::{ - extract::{ContentLengthLimit, Extension, UrlParams}, - prelude::*, - response::IntoResponse, - routing::BoxRoute, -}; #[tokio::main] async fn main() { diff --git a/examples/static_file_server.rs b/examples/static_file_server.rs index 295bf081..8c8b63f8 100644 --- a/examples/static_file_server.rs +++ b/examples/static_file_server.rs @@ -1,15 +1,15 @@ +use awebframework::{prelude::*, service::ServiceExt}; use http::StatusCode; use std::net::SocketAddr; use tower_http::{services::ServeDir, trace::TraceLayer}; -use tower_web::{prelude::*, service::ServiceExt}; #[tokio::main] async fn main() { tracing_subscriber::fmt::init(); - let app = tower_web::routing::nest( + let app = awebframework::routing::nest( "/static", - tower_web::service::get(ServeDir::new(".").handle_error(|error: std::io::Error| { + awebframework::service::get(ServeDir::new(".").handle_error(|error: std::io::Error| { ( StatusCode::INTERNAL_SERVER_ERROR, format!("Unhandled interal error: {}", error), diff --git a/examples/websocket.rs b/examples/websocket.rs index 4db23a2a..1e1526c5 100644 --- a/examples/websocket.rs +++ b/examples/websocket.rs @@ -9,18 +9,18 @@ //! --example websocket //! ``` +use awebframework::{ + prelude::*, + routing::nest, + service::ServiceExt, + ws::{ws, Message, WebSocket}, +}; use http::StatusCode; use std::net::SocketAddr; use tower_http::{ services::ServeDir, trace::{DefaultMakeSpan, TraceLayer}, }; -use tower_web::{ - prelude::*, - routing::nest, - service::ServiceExt, - ws::{ws, Message, WebSocket}, -}; #[tokio::main] async fn main() { @@ -29,7 +29,7 @@ async fn main() { // build our application with some routes let app = nest( "/", - tower_web::service::get( + awebframework::service::get( ServeDir::new("examples/websocket") .append_index_html_on_directories(true) .handle_error(|error: std::io::Error| { diff --git a/src/body.rs b/src/body.rs index 33ac1960..9bcbdc56 100644 --- a/src/body.rs +++ b/src/body.rs @@ -14,7 +14,7 @@ pub use hyper::body::Body; /// A boxed [`Body`] trait object. /// -/// This is used in tower-web as the response body type for applications. Its necessary to unify +/// This is used in awebframework as the response body type for applications. Its necessary to unify /// multiple response bodies types into one. pub struct BoxBody { // when we've gotten rid of `BoxStdError` we should be able to change the error type to diff --git a/src/extract/mod.rs b/src/extract/mod.rs index 8567d639..58898807 100644 --- a/src/extract/mod.rs +++ b/src/extract/mod.rs @@ -8,7 +8,7 @@ //! deserializes it as JSON into some target type: //! //! ```rust,no_run -//! use tower_web::prelude::*; +//! use awebframework::prelude::*; //! use serde::Deserialize; //! //! #[derive(Deserialize)] @@ -34,7 +34,7 @@ //! You can also define your own extractors by implementing [`FromRequest`]: //! //! ```rust,no_run -//! use tower_web::{async_trait, extract::FromRequest, prelude::*}; +//! use awebframework::{async_trait, extract::FromRequest, prelude::*}; //! use http::{StatusCode, header::{HeaderValue, USER_AGENT}}; //! //! struct ExtractUserAgent(HeaderValue); @@ -69,7 +69,7 @@ //! Handlers can also contain multiple extractors: //! //! ```rust,no_run -//! use tower_web::prelude::*; +//! use awebframework::prelude::*; //! use std::collections::HashMap; //! //! async fn handler( @@ -94,7 +94,7 @@ //! Wrapping extractors in `Option` will make them optional: //! //! ```rust,no_run -//! use tower_web::{extract::Json, prelude::*}; +//! use awebframework::{extract::Json, prelude::*}; //! use serde_json::Value; //! //! async fn create_user(payload: Option>) { @@ -117,7 +117,7 @@ //! directly on the function signature: //! //! ```rust,no_run -//! use tower_web::{extract::Json, prelude::*}; +//! use awebframework::{extract::Json, prelude::*}; //! use serde_json::Value; //! //! async fn create_user(Json(value): Json) { @@ -177,7 +177,7 @@ where /// # Example /// /// ```rust,no_run -/// use tower_web::prelude::*; +/// use awebframework::prelude::*; /// use serde::Deserialize; /// /// #[derive(Deserialize)] @@ -230,7 +230,7 @@ where /// # Example /// /// ```rust,no_run -/// use tower_web::prelude::*; +/// use awebframework::prelude::*; /// use serde::Deserialize; /// /// #[derive(Deserialize)] @@ -297,7 +297,7 @@ where /// # Example /// /// ```rust,no_run -/// use tower_web::prelude::*; +/// use awebframework::prelude::*; /// use serde::Deserialize; /// /// #[derive(Deserialize)] @@ -374,7 +374,7 @@ fn has_content_type(req: &Request, expected_content_type: &str) -> bool { /// # Example /// /// ```rust,no_run -/// use tower_web::{AddExtensionLayer, prelude::*}; +/// use awebframework::{AddExtensionLayer, prelude::*}; /// use std::sync::Arc; /// /// // Some shared state used throughout our application @@ -523,7 +523,7 @@ impl FromRequest for HeaderMap { /// # Example /// /// ```rust,no_run -/// use tower_web::prelude::*; +/// use awebframework::prelude::*; /// /// async fn handler(body: extract::ContentLengthLimit) { /// // ... @@ -570,7 +570,7 @@ where /// # Example /// /// ```rust,no_run -/// use tower_web::prelude::*; +/// use awebframework::prelude::*; /// /// async fn users_show(params: extract::UrlParamsMap) { /// let id: Option<&str> = params.get("id"); @@ -626,7 +626,7 @@ impl FromRequest for UrlParamsMap { /// # Example /// /// ```rust,no_run -/// use tower_web::{extract::UrlParams, prelude::*}; +/// use awebframework::{extract::UrlParams, prelude::*}; /// use uuid::Uuid; /// /// async fn users_teams_show( diff --git a/src/extract/rejection.rs b/src/extract/rejection.rs index 4e156aaf..51c481cc 100644 --- a/src/extract/rejection.rs +++ b/src/extract/rejection.rs @@ -120,7 +120,7 @@ define_rejection! { define_rejection! { #[status = INTERNAL_SERVER_ERROR] - #[body = "No url params found for matched route. This is a bug in tower-web. Please open an issue"] + #[body = "No url params found for matched route. This is a bug in awebframework. Please open an issue"] /// Rejection type for [`UrlParamsMap`](super::UrlParamsMap) and /// [`UrlParams`](super::UrlParams) if you try and extract the URL params /// more than once. diff --git a/src/handler/mod.rs b/src/handler/mod.rs index 1b1f0161..6999e00d 100644 --- a/src/handler/mod.rs +++ b/src/handler/mod.rs @@ -2,7 +2,7 @@ //! //! # What is a handler? //! -//! In tower-web a "handler" is an async function that accepts zero or more +//! In awebframework a "handler" is an async function that accepts zero or more //! ["extractors"](crate::extract) as arguments and returns something that //! implements [`IntoResponse`]. //! @@ -11,7 +11,7 @@ //! Some examples of handlers: //! //! ```rust -//! use tower_web::prelude::*; +//! use awebframework::prelude::*; //! use bytes::Bytes; //! use http::StatusCode; //! @@ -65,7 +65,7 @@ pub mod future; /// # Example /// /// ```rust -/// use tower_web::prelude::*; +/// use awebframework::prelude::*; /// /// async fn handler() {} /// @@ -104,7 +104,7 @@ where /// # Example /// /// ```rust -/// use tower_web::prelude::*; +/// use awebframework::prelude::*; /// /// async fn handler() {} /// @@ -183,7 +183,7 @@ where /// # Example /// /// ```rust -/// use tower_web::{handler::on, routing::MethodFilter, prelude::*}; +/// use awebframework::{handler::on, routing::MethodFilter, prelude::*}; /// /// async fn handler() {} /// @@ -242,7 +242,7 @@ pub trait Handler: Sized { /// can be done like so: /// /// ```rust - /// use tower_web::prelude::*; + /// use awebframework::prelude::*; /// use tower::limit::{ConcurrencyLimitLayer, ConcurrencyLimit}; /// /// async fn handler() { /* ... */ } @@ -381,14 +381,14 @@ impl Layered { /// Create a new [`Layered`] handler where errors will be handled using the /// given closure. /// - /// tower-web requires that services gracefully handles all errors. That + /// awebframework requires that services gracefully handles all errors. That /// means when you apply a Tower middleware that adds a new failure /// condition you have to handle that as well. /// /// That can be done using `handle_error` like so: /// /// ```rust - /// use tower_web::prelude::*; + /// use awebframework::prelude::*; /// use http::StatusCode; /// use tower::{BoxError, timeout::TimeoutLayer}; /// use std::time::Duration; @@ -538,7 +538,7 @@ impl OnMethod { /// # Example /// /// ```rust - /// use tower_web::prelude::*; + /// use awebframework::prelude::*; /// /// async fn handler() {} /// @@ -621,7 +621,7 @@ impl OnMethod { /// # Example /// /// ```rust - /// use tower_web::{routing::MethodFilter, prelude::*}; + /// use awebframework::{routing::MethodFilter, prelude::*}; /// /// async fn handler() {} /// diff --git a/src/lib.rs b/src/lib.rs index 0b1f3c9f..70f1703c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,28 +1,28 @@ -//! tower-web (name pending) is a tiny web application framework that focuses on +//! awebframework (name pending) is a tiny web application framework that focuses on //! ergonomics and modularity. //! //! ## Goals //! //! - Ease of use. Building web apps in Rust should be as easy as `async fn //! handle(Request) -> Response`. -//! - Solid foundation. tower-web is built on top of tower and makes it easy to +//! - Solid foundation. awebframework is built on top of tower and makes it easy to //! plug in any middleware from the [tower] and [tower-http] ecosystem. //! - Focus on routing, extracting data from requests, and generating responses. //! Tower middleware can handle the rest. -//! - Macro free core. Macro frameworks have their place but tower-web focuses +//! - Macro free core. Macro frameworks have their place but awebframework focuses //! on providing a core that is macro free. //! //! # Compatibility //! -//! tower-web is designed to work with [tokio] and [hyper]. Runtime and +//! awebframework is designed to work with [tokio] and [hyper]. Runtime and //! transport layer independence is not a goal, at least for the time being. //! //! # Example //! -//! The "Hello, World!" of tower-web is: +//! The "Hello, World!" of awebframework is: //! //! ```rust,no_run -//! use tower_web::prelude::*; +//! use awebframework::prelude::*; //! use hyper::Server; //! use std::net::SocketAddr; //! use tower::make::Shared; @@ -45,7 +45,7 @@ //! Routing between handlers looks like this: //! //! ```rust,no_run -//! use tower_web::prelude::*; +//! use awebframework::prelude::*; //! //! let app = route("/", get(get_slash).post(post_slash)) //! .route("/foo", get(get_foo)); @@ -75,7 +75,7 @@ //! returned from a handler: //! //! ```rust,no_run -//! use tower_web::{body::Body, response::{Html, Json}, prelude::*}; +//! use awebframework::{body::Body, response::{Html, Json}, prelude::*}; //! use http::{StatusCode, Response, Uri}; //! use serde_json::{Value, json}; //! @@ -157,7 +157,7 @@ //! body and deserializes it as JSON into some target type: //! //! ```rust,no_run -//! use tower_web::prelude::*; +//! use awebframework::prelude::*; //! use serde::Deserialize; //! //! let app = route("/users", post(create_user)); @@ -183,7 +183,7 @@ //! [`Uuid`]: //! //! ```rust,no_run -//! use tower_web::prelude::*; +//! use awebframework::prelude::*; //! use uuid::Uuid; //! //! let app = route("/users/:id", post(create_user)); @@ -204,7 +204,7 @@ //! You can also apply multiple extractors: //! //! ```rust,no_run -//! use tower_web::prelude::*; +//! use awebframework::prelude::*; //! use uuid::Uuid; //! use serde::Deserialize; //! @@ -239,7 +239,7 @@ //! Additionally `Request` is itself an extractor: //! //! ```rust,no_run -//! use tower_web::prelude::*; +//! use awebframework::prelude::*; //! //! let app = route("/users/:id", post(handler)); //! @@ -260,7 +260,7 @@ //! //! # Applying middleware //! -//! tower-web is designed to take full advantage of the tower and tower-http +//! awebframework is designed to take full advantage of the tower and tower-http //! ecosystem of middleware: //! //! ## Applying middleware to individual handlers @@ -268,7 +268,7 @@ //! A middleware can be applied to a single handler like so: //! //! ```rust,no_run -//! use tower_web::prelude::*; +//! use awebframework::prelude::*; //! use tower::limit::ConcurrencyLimitLayer; //! //! let app = route( @@ -287,7 +287,7 @@ //! Middleware can also be applied to a group of routes like so: //! //! ```rust,no_run -//! use tower_web::prelude::*; +//! use awebframework::prelude::*; //! use tower::limit::ConcurrencyLimitLayer; //! //! let app = route("/", get(get_slash)) @@ -304,7 +304,7 @@ //! //! ## Error handling //! -//! tower-web requires all errors to be handled. That is done by using +//! awebframework requires all errors to be handled. That is done by using //! [`std::convert::Infallible`] as the error type in all its [`Service`] //! implementations. //! @@ -313,11 +313,11 @@ //! [`IntoResponse`](response::IntoResponse), even if its a `Result`. //! //! However middleware might add new failure cases that has to be handled. For -//! that tower-web provides a [`handle_error`](handler::Layered::handle_error) +//! that awebframework provides a [`handle_error`](handler::Layered::handle_error) //! combinator: //! //! ```rust,no_run -//! use tower_web::prelude::*; +//! use awebframework::prelude::*; //! use tower::{ //! BoxError, timeout::{TimeoutLayer, error::Elapsed}, //! }; @@ -359,7 +359,7 @@ //! group of routes with middleware applied: //! //! ```rust,no_run -//! use tower_web::prelude::*; +//! use awebframework::prelude::*; //! use tower::{BoxError, timeout::TimeoutLayer}; //! use std::time::Duration; //! @@ -383,7 +383,7 @@ //! [`tower::ServiceBuilder`] can be used to combine multiple middleware: //! //! ```rust,no_run -//! use tower_web::prelude::*; +//! use awebframework::prelude::*; //! use tower::{ //! ServiceBuilder, BoxError, //! load_shed::error::Overloaded, @@ -439,7 +439,7 @@ //! and the [`extract::Extension`] extractor: //! //! ```rust,no_run -//! use tower_web::{AddExtensionLayer, prelude::*}; +//! use awebframework::{AddExtensionLayer, prelude::*}; //! use std::sync::Arc; //! //! struct State { @@ -464,10 +464,10 @@ //! //! # Routing to any [`Service`] //! -//! tower-web also supports routing to general [`Service`]s: +//! awebframework also supports routing to general [`Service`]s: //! //! ```rust,no_run -//! use tower_web::{ +//! use awebframework::{ //! // `ServiceExt` adds `handle_error` to any `Service` //! service::{self, ServiceExt}, prelude::*, //! }; @@ -505,7 +505,7 @@ //! Applications can be nested by calling [`nest`](routing::nest): //! //! ```rust,no_run -//! use tower_web::{prelude::*, routing::BoxRoute, body::BoxBody}; +//! use awebframework::{prelude::*, routing::BoxRoute, body::BoxBody}; //! use tower_http::services::ServeFile; //! use http::Response; //! use std::convert::Infallible; @@ -524,7 +524,7 @@ //! [`nest`](routing::nest) can also be used to serve static files from a directory: //! //! ```rust,no_run -//! use tower_web::{prelude::*, service::ServiceExt, routing::nest}; +//! use awebframework::{prelude::*, service::ServiceExt, routing::nest}; //! use tower_http::services::ServeDir; //! use http::Response; //! use std::convert::Infallible; @@ -543,7 +543,7 @@ //! //! # Features //! -//! tower-web uses a set of [feature flags] to reduce the amount of compiled and +//! awebframework uses a set of [feature flags] to reduce the amount of compiled and //! optional dependencies. //! //! The following optional features are available: @@ -632,7 +632,7 @@ pub use async_trait::async_trait; pub use tower_http::add_extension::{AddExtension, AddExtensionLayer}; pub mod prelude { - //! Re-exports of important traits, types, and functions used with tower-web. Meant to be glob + //! Re-exports of important traits, types, and functions used with awebframework. Meant to be glob //! imported. pub use crate::body::Body; @@ -667,7 +667,7 @@ pub mod prelude { /// # Examples /// /// ```rust -/// use tower_web::prelude::*; +/// use awebframework::prelude::*; /// # use std::convert::Infallible; /// # use http::Response; /// # let service = tower::service_fn(|_: Request| async { diff --git a/src/response.rs b/src/response.rs index dea64edd..4fcd46a0 100644 --- a/src/response.rs +++ b/src/response.rs @@ -198,7 +198,7 @@ where /// /// ``` /// use serde_json::json; -/// use tower_web::{body::Body, response::{Json, IntoResponse}}; +/// use awebframework::{body::Body, response::{Json, IntoResponse}}; /// use http::{Response, header::CONTENT_TYPE}; /// /// let json = json!({ diff --git a/src/routing.rs b/src/routing.rs index 897ad7cf..8eb10746 100644 --- a/src/routing.rs +++ b/src/routing.rs @@ -89,7 +89,7 @@ pub trait RoutingDsl: crate::sealed::Sealed + Sized { /// # Example /// /// ```rust - /// use tower_web::prelude::*; + /// use awebframework::prelude::*; /// /// async fn first_handler() { /* ... */ } /// @@ -133,7 +133,7 @@ pub trait RoutingDsl: crate::sealed::Sealed + Sized { /// return them from functions: /// /// ```rust - /// use tower_web::{routing::BoxRoute, prelude::*}; + /// use awebframework::{routing::BoxRoute, prelude::*}; /// /// async fn first_handler() { /* ... */ } /// @@ -182,7 +182,7 @@ pub trait RoutingDsl: crate::sealed::Sealed + Sized { /// routes can be done like so: /// /// ```rust - /// use tower_web::prelude::*; + /// use awebframework::prelude::*; /// use tower::limit::{ConcurrencyLimitLayer, ConcurrencyLimit}; /// /// async fn first_handler() { /* ... */ } @@ -208,7 +208,7 @@ pub trait RoutingDsl: crate::sealed::Sealed + Sized { /// entire app: /// /// ```rust - /// use tower_web::prelude::*; + /// use awebframework::prelude::*; /// use tower_http::trace::TraceLayer; /// /// async fn first_handler() { /* ... */ } @@ -240,7 +240,7 @@ pub trait RoutingDsl: crate::sealed::Sealed + Sized { /// [`Server`](hyper::server::Server): /// /// ``` - /// use tower_web::prelude::*; + /// use awebframework::prelude::*; /// /// let app = route("/", get(|| async { "Hi!" })); /// @@ -578,7 +578,7 @@ fn handle_buffer_error(error: BoxError) -> Response { Ok(service_error) => { return Response::builder() .status(StatusCode::INTERNAL_SERVER_ERROR) - .body(BoxBody::new(Full::from(format!("Service error: {}. This is a bug in tower-web. All inner services should be infallible. Please file an issue", service_error)))) + .body(BoxBody::new(Full::from(format!("Service error: {}. This is a bug in awebframework. All inner services should be infallible. Please file an issue", service_error)))) .unwrap(); } Err(e) => e, @@ -607,14 +607,14 @@ impl Layered { /// Create a new [`Layered`] service where errors will be handled using the /// given closure. /// - /// tower-web requires that services gracefully handles all errors. That + /// awebframework requires that services gracefully handles all errors. That /// means when you apply a Tower middleware that adds a new failure /// condition you have to handle that as well. /// /// That can be done using `handle_error` like so: /// /// ```rust - /// use tower_web::prelude::*; + /// use awebframework::prelude::*; /// use http::StatusCode; /// use tower::{BoxError, timeout::TimeoutLayer}; /// use std::time::Duration; @@ -680,7 +680,7 @@ where /// nested route will only see the part of URL: /// /// ``` -/// use tower_web::{routing::nest, prelude::*}; +/// use awebframework::{routing::nest, prelude::*}; /// use http::Uri; /// /// async fn users_get(uri: Uri) { @@ -705,7 +705,7 @@ where /// captures from the outer routes: /// /// ``` -/// use tower_web::{routing::nest, prelude::*}; +/// use awebframework::{routing::nest, prelude::*}; /// /// async fn users_get(params: extract::UrlParamsMap) { /// // Both `version` and `id` were captured even though `users_api` only @@ -726,7 +726,7 @@ where /// [`tower_http::services::ServeDir`] to serve static files from a directory: /// /// ``` -/// use tower_web::{ +/// use awebframework::{ /// routing::nest, service::{get, ServiceExt}, prelude::*, /// }; /// use tower_http::services::ServeDir; diff --git a/src/service/mod.rs b/src/service/mod.rs index 04f0b05e..307bf804 100644 --- a/src/service/mod.rs +++ b/src/service/mod.rs @@ -11,7 +11,7 @@ //! //! ``` //! use tower_http::services::Redirect; -//! use tower_web::{service, handler, prelude::*}; +//! use awebframework::{service, handler, prelude::*}; //! //! async fn handler(request: Request) { /* ... */ } //! @@ -41,7 +41,7 @@ //! well when your services don't care about backpressure and are always ready //! anyway. //! -//! tower-web expects that all services used in your app wont care about +//! awebframework expects that all services used in your app wont care about //! backpressure and so it uses the latter strategy. However that means you //! should avoid routing to a service (or using a middleware) that _does_ care //! about backpressure. At the very least you should [load shed] so requests are @@ -51,14 +51,14 @@ //! in the response future from `call`, and _not_ from `poll_ready`. In that //! case the underlying service will _not_ be discarded and will continue to be //! used for future requests. Services that expect to be discarded if -//! `poll_ready` fails should _not_ be used with tower-web. +//! `poll_ready` fails should _not_ be used with awebframework. //! //! One possible approach is to only apply backpressure sensitive middleware -//! around your entire app. This is possible because tower-web applications are +//! around your entire app. This is possible because awebframework applications are //! themselves services: //! //! ```rust -//! use tower_web::prelude::*; +//! use awebframework::prelude::*; //! use tower::ServiceBuilder; //! # let some_backpressure_sensitive_middleware = //! # tower::layer::util::Identity::new(); @@ -137,7 +137,7 @@ where /// # Example /// /// ```rust -/// use tower_web::{service, prelude::*}; +/// use awebframework::{service, prelude::*}; /// use http::Response; /// use std::convert::Infallible; /// use hyper::Body; @@ -224,7 +224,7 @@ where /// # Example /// /// ```rust -/// use tower_web::{handler::on, service, routing::MethodFilter, prelude::*}; +/// use awebframework::{handler::on, service, routing::MethodFilter, prelude::*}; /// use http::Response; /// use std::convert::Infallible; /// use hyper::Body; @@ -293,7 +293,7 @@ impl OnMethod { /// # Example /// /// ```rust - /// use tower_web::{handler::on, service, routing::MethodFilter, prelude::*}; + /// use awebframework::{handler::on, service, routing::MethodFilter, prelude::*}; /// use http::Response; /// use std::convert::Infallible; /// use hyper::Body; @@ -387,7 +387,7 @@ impl OnMethod { /// # Example /// /// ```rust - /// use tower_web::{handler::on, service, routing::MethodFilter, prelude::*}; + /// use awebframework::{handler::on, service, routing::MethodFilter, prelude::*}; /// use http::Response; /// use std::convert::Infallible; /// use hyper::Body; @@ -503,9 +503,9 @@ where pub trait ServiceExt: Service, Response = Response> { /// Handle errors from a service. /// - /// tower-web requires all handlers and services, that are part of the + /// awebframework requires all handlers and services, that are part of the /// router, to never return errors. If you route to [`Service`], not created - /// by tower-web, who's error isn't `Infallible` you can use this combinator + /// by awebframework, who's error isn't `Infallible` you can use this combinator /// to handle the error. /// /// `handle_error` takes a closure that will map errors from the service @@ -515,7 +515,7 @@ pub trait ServiceExt: Service, Response = Response> { /// # Example /// /// ```rust,no_run - /// use tower_web::{service::{self, ServiceExt}, prelude::*}; + /// use awebframework::{service::{self, ServiceExt}, prelude::*}; /// use http::Response; /// use tower::{service_fn, BoxError}; /// diff --git a/src/ws/mod.rs b/src/ws/mod.rs index bd11663b..29269645 100644 --- a/src/ws/mod.rs +++ b/src/ws/mod.rs @@ -3,7 +3,7 @@ //! # Example //! //! ``` -//! use tower_web::{prelude::*, ws::{ws, WebSocket}}; +//! use awebframework::{prelude::*, ws::{ws, WebSocket}}; //! //! let app = route("/ws", ws(handle_socket)); //!