

Tower Web – A fast, boilerplate free, web framework for Rust
source link: https://www.tuicool.com/articles/hit/q2eaeqZ
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Tower Web
A web framework for Rust with a focus on removing boilerplate.
Tower Web is:
- Fast : Fully asynchronous, built on Tokio and Hyper .
- Ergonomic : Tower-web decouples HTTP from your application logic, removing all boilerplate.
- Works on Rust stable : You can use it today.
Hello World
#[macro_use] extern crate tower_web; extern crate tokio; use tower_web::ServiceBuilder; use tokio::prelude::*; /// This type will be part of the web service as a resource. #[derive(Clone, Debug)] struct HelloWorld; /// This will be the JSON response #[derive(Response)] struct HelloResponse { message: &'static str, } impl_web! { impl HelloWorld { #[get("/")] #[content_type("json")] fn hello_world(&self) -> Result<HelloResponse, ()> { Ok(HelloResponse { message: "hello world", }) } } } pub fn main() { let addr = "127.0.0.1:8080".parse().expect("Invalid address"); println!("Listening on http://{}", addr); ServiceBuilder::new() .resource(HelloWorld) .run(&addr) .unwrap(); }
Overview
Tower Web aims to decouple all HTTP concepts from the application logic. You define a "plain old Rust method" (PORM?). This method takes only the data it needs to complete and returns a struct representing the response. Tower Web does the rest.
The impl_web
macro looks at the definition and generates the glue code,
allowing the method to respond to HTTP requests.
Getting Started
The best way to get started is to read the examples and API docs .
License
This project is licensed under the MIT 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
additional terms or conditions.
Recommend
-
83
Overview The quick development boilerplate based on Spring (Boot) Framework which covers the general case of Java backend application something like Account Module, Security Foundation, Audit System, File Upload/Download, Message Notifica...
-
45
README.md Bash Infinity
-
40
README.md Molten-Boilerplate What's included? SQLAlchemy alembic camelCase API py.test (with coverage)
-
14
Rust live coding - Tower deep dive1,568 views•Jan 15, 2021720ShareSave ...
-
28
axum is a web application framework that focuses on ergonomics and modularity. More information about this crate can be found in the crate documentation. High level features...
-
8
[Free][Game] Tower Ball Blast - Free Arcade Stack Ball Game ...
-
6
Fast byte searching with SIMD without a ton of boilerplate? TL;DR: I’m looking for a SIMD abstraction layer that will let me do some high-speed byte searching without having to worry about a dozen different...
-
9
Fast Development With NodeJS: NestJS BoilerplateNotificationsHappy Weekend, enjoy these top stories from this week, Kaiseki, PIRATES, and more 💚Last Saturday at 6:00 PMHappy Weekend...
-
6
NestJS boilerplate is a project that contains all necessary libraries and solutions like auth, mailing, etc. for fast-starting your project using a classic REST API appr...
-
9
Welcome to Tower Brawl! Casual and competitive game that combines elements of tower defense, real-time strategy and card game genres. Unlike normal tower defense games, Tower Brawl features a new siege tower battle game style with a variety of h...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK