axum/README.md

86 lines
2.8 KiB
Markdown
Raw Normal View History

2021-05-31 16:28:26 +02:00
# tower-web
2021-06-12 20:18:21 +02:00
**WARNING:** tower-web is very much still work in progress. Nothing is released
to crates.io yet and you shouldn't be using this in production.
2021-06-06 15:20:27 +02:00
tower-web (name pending) is a tiny web application framework that focuses on
2021-06-07 16:31:11 +02:00
ergonomics and modularity.
2021-05-31 16:28:26 +02:00
2021-06-12 20:18:21 +02:00
[![Build status](https://github.com/davidpdrsn/tower-web/workflows/CI/badge.svg)](https://github.com/davidpdrsn/tower-web/actions)
<!--
[![Crates.io](https://img.shields.io/crates/v/tower-web)](https://crates.io/crates/tower-web)
[![Documentation](https://docs.rs/tower-web/badge.svg)](https://docs.rs/tower-web)
[![Crates.io](https://img.shields.io/crates/l/tower-web)](LICENSE)
-->
More information about this crate can be found in the [crate documentation][docs].
## Goals
2021-05-31 16:28:26 +02:00
2021-06-06 20:39:54 +02:00
- Ease of use. Building web apps in Rust should be as easy as `async fn
2021-06-06 15:20:27 +02:00
handle(Request) -> Response`.
- Solid foundation. tower-web is built on top of tower and makes it easy to
plug in any middleware from the [tower] and [tower-http] ecosystem.
2021-06-07 16:31:11 +02:00
- Focus on routing, extracting data from requests, and generating responses.
2021-06-08 21:21:20 +02:00
Tower middleware can handle the rest.
2021-06-06 15:20:27 +02:00
- Macro free core. Macro frameworks have their place but tower-web focuses
on providing a core that is macro free.
2021-05-31 16:28:26 +02:00
2021-06-12 20:18:21 +02:00
## Usage example
2021-05-31 16:28:26 +02:00
2021-06-06 15:20:27 +02:00
```rust
use tower_web::prelude::*;
use hyper::Server;
use std::net::SocketAddr;
use tower::make::Shared;
2021-06-01 00:47:12 +02:00
2021-06-06 15:20:27 +02:00
#[tokio::main]
async fn main() {
// build our application with a single route
2021-06-09 09:03:09 +02:00
let app = route("/", get(|| async { "Hello, World!" }));
2021-05-31 16:28:26 +02:00
2021-06-06 15:20:27 +02:00
// run it with hyper on localhost:3000
let addr = SocketAddr::from(([127, 0, 0, 1], 3000));
2021-06-08 21:21:20 +02:00
Server::bind(&addr)
.serve(Shared::new(app))
.await
.unwrap();
2021-06-06 15:20:27 +02:00
}
2021-05-31 16:28:26 +02:00
```
2021-06-12 20:18:21 +02:00
## Examples
2021-06-09 09:03:09 +02:00
2021-06-12 20:18:21 +02:00
The [examples] folder contains various examples of how to use tower-web. The
[docs] also have lots of examples
2021-05-31 16:28:26 +02:00
2021-06-12 20:18:21 +02:00
## Getting Help
2021-06-06 15:20:27 +02:00
2021-06-12 20:18:21 +02:00
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.
2021-06-08 21:21:20 +02:00
2021-06-12 20:18:21 +02:00
## Contributing
2021-05-31 16:28:26 +02:00
2021-06-12 20:18:21 +02:00
: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.
2021-06-06 15:20:27 +02:00
2021-06-12 20:18:21 +02:00
## License
2021-06-06 15:20:27 +02:00
2021-06-12 20:18:21 +02:00
This project is licensed under the [MIT license](LICENSE).
2021-05-31 16:28:26 +02:00
2021-06-12 20:18:21 +02:00
### Contribution
2021-06-06 15:20:27 +02:00
2021-06-12 20:18:21 +02:00
Unless you explicitly state otherwise, any contribution intentionally submitted
for inclusion in tower-web by you, shall be licensed as MIT, without any
additional terms or conditions.
2021-06-07 16:31:11 +02:00
2021-06-12 20:18:21 +02:00
[examples]: https://github.com/davidpdrsn/tower-web/tree/master/examples
[docs]: https://docs.rs/tower-http/0.1.0
2021-06-06 15:20:27 +02:00
[tower]: https://crates.io/crates/tower
[tower-http]: https://crates.io/crates/tower-http
2021-06-12 20:18:21 +02:00
[guide]: CONTRIBUTING.md
[chat]: https://discord.gg/tokio
[issue]: https://github.com/davidpdrsn/tower-web/issues/new