11 releases

0.1.12 Oct 31, 2023
0.1.11 Oct 19, 2023
0.1.10 Sep 2, 2023
0.1.9 Aug 10, 2023
0.1.0 Aug 4, 2019

#280 in HTTP server

Download history 12/week @ 2024-09-18 27/week @ 2024-09-25

87 downloads per month

MIT license

335KB
633 lines

gotcha

provide a featured web framework

aim to

  • everything of axum
  • automatically swagger api generation
  • built-in message mechanism
  • environment based configuration system, support environment resolver ${ANY_ENV_VAR} and path variable ${app.database.name} powered by yaac
  • logging system
  • opt-in prometheus integration
  • sqlx based magic ORM
  • cron-based task system

get started

add dependency into Cargo.toml

gotcha = {version = "0.1"}
tokio = {version = "1", features = ["macros", 'rt-multi-thread']}
serde = {version="1", features=["derive"]}
use serde::Deserialize;

use gotcha::{get, GotchaApp, GotchaConfigLoader, Responder, State};
use gotcha::axum::extract::FromRef;

pub(crate) async fn hello_world(_state: State<Config>) -> impl Responder {
    "hello world"
}

#[derive(Debug, Deserialize, Clone)]
pub(crate) struct Config {}

#[tokio::main]
async fn main() {
    let config: Config = GotchaConfigLoader::load(None);
    GotchaApp::new().get("/", hello_world)
        .data(config)
        .done()
        .serve("127.0.0.1", 8000).await
}

Dependencies

~24–36MB
~622K SLoC