simple-api 0.1.0

A simple web framework for learing Rust
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
use crate::{context::Context, types::HttpRequest};
use crate::types::HttpResonse;
use async_trait::async_trait;
use hyper::{Method};
use regex::Regex;

#[async_trait]
pub trait View: Send + Sync {
    async fn call(&self, req: &mut HttpRequest, ctx: &mut Context)
        -> anyhow::Result<HttpResonse>;
    fn methods(&self) -> Vec<Method>;
    fn re_path(&self) -> Regex;
}