2021-06-13 11:22:02 +02:00
|
|
|
# awebframework
|
2021-05-31 16:28:26 +02:00
|
|
|
|
2021-06-13 11:22:02 +02:00
|
|
|
**WARNING:** awebframework is very much still work in progress. Nothing is released
|
2021-06-12 20:18:21 +02:00
|
|
|
to crates.io yet and you shouldn't be using this in production.
|
|
|
|
|
2021-06-13 11:22:02 +02:00
|
|
|
awebframework (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-13 11:22:02 +02:00
|
|
|
[](https://github.com/davidpdrsn/awebframework/actions)
|
2021-06-12 20:18:21 +02:00
|
|
|
<!--
|
2021-06-13 11:22:02 +02:00
|
|
|
[](https://crates.io/crates/awebframework)
|
|
|
|
[](https://docs.rs/awebframework)
|
|
|
|
[](LICENSE)
|
2021-06-12 20:18:21 +02:00
|
|
|
-->
|
|
|
|
|
|
|
|
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`.
|
2021-06-13 11:22:02 +02:00
|
|
|
- Solid foundation. awebframework is built on top of tower and makes it easy to
|
2021-06-06 15:20:27 +02:00
|
|
|
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-13 11:22:02 +02:00
|
|
|
- Macro free core. Macro frameworks have their place but awebframework focuses
|
2021-06-06 15:20:27 +02:00
|
|
|
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
|
2021-06-13 11:22:02 +02:00
|
|
|
use awebframework::prelude::*;
|
2021-06-06 15:20:27 +02:00
|
|
|
use hyper::Server;
|
|
|
|
use std::net::SocketAddr;
|
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)
|
2021-06-13 13:09:24 +02:00
|
|
|
.serve(app.into_make_service())
|
2021-06-08 21:21:20 +02:00
|
|
|
.await
|
|
|
|
.unwrap();
|
2021-06-06 15:20:27 +02:00
|
|
|
}
|
2021-05-31 16:28:26 +02:00
|
|
|
```
|
|
|
|
|
2021-06-13 13:09:24 +02:00
|
|
|
See the [crate documentation][docs] for way more examples.
|
|
|
|
|
2021-06-12 20:18:21 +02:00
|
|
|
## Examples
|
2021-06-09 09:03:09 +02:00
|
|
|
|
2021-06-13 11:22:02 +02:00
|
|
|
The [examples] folder contains various examples of how to use awebframework. The
|
2021-06-12 20:18:21 +02:00
|
|
|
[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-13 11:22:02 +02: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-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
|
2021-06-13 11:22:02 +02:00
|
|
|
awebframework 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
|
2021-06-13 11:22:02 +02:00
|
|
|
for inclusion in awebframework by you, shall be licensed as MIT, without any
|
2021-06-12 20:18:21 +02:00
|
|
|
additional terms or conditions.
|
2021-06-07 16:31:11 +02:00
|
|
|
|
2021-06-13 11:22:02 +02:00
|
|
|
[examples]: https://github.com/davidpdrsn/awebframework/tree/master/examples
|
2021-06-13 13:11:57 +02:00
|
|
|
[docs]: https://docs.rs/awebframework/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
|
2021-06-13 11:22:02 +02:00
|
|
|
[issue]: https://github.com/davidpdrsn/awebframework/issues/new
|