Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/daog1/rflask
actix-web flask decorator
https://github.com/daog1/rflask
actix-web flask web
Last synced: 1 day ago
JSON representation
actix-web flask decorator
- Host: GitHub
- URL: https://github.com/daog1/rflask
- Owner: daog1
- License: mit
- Created: 2019-09-16T03:47:20.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2019-09-22T10:41:00.000Z (about 5 years ago)
- Last Synced: 2024-11-11T14:37:47.188Z (5 days ago)
- Topics: actix-web, flask, web
- Language: Rust
- Homepage:
- Size: 24.4 KB
- Stars: 16
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# Actix web flask decorator
* Cargo package: [awf-help](https://crates.io/crates/awf-help)
## Example
```rust
extern crate awf_help;
use actix_web::{web, App, HttpRequest, HttpServer, Responder};
use awf_help::{config, route,route_res, ServiceFactory};
#[route(GET, "/")]
fn greet(req: HttpRequest) -> String {
let name = req.match_info().get("name").unwrap_or("World");
format!("Hello {}!", &name)
}
struct Hello{
}
#[route_res("/api/auth")]
impl Hello {
fn get(req: HttpRequest) -> String {
format!("get Hello !")
}
fn post(req: HttpRequest) -> String {
format!("post Hello !")
}
}
fn main() {
HttpServer::new(|| App::new().configure(config))
.bind("127.0.0.1:8000")
.expect("Can not bind to port 8000")
.run()
.unwrap();
}
```