axum/README.md

86 lines
2.9 KiB
Markdown
Raw Normal View History

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