Skip to content

Commit

Permalink
bump: gotcha v0.2.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Kilerd committed Dec 31, 2024
1 parent 24f0c76 commit 29e8127
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 14 deletions.
40 changes: 27 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,39 @@ tokio = {version = "1", features = ["macros", 'rt-multi-thread']}
serde = {version="1", features=["derive"]}
```
```rust
use serde::Deserialize;
use gotcha::{async_trait, ConfigWrapper, GotchaApp, GotchaContext, GotchaRouter, Responder, State};
use serde::{Deserialize, Serialize};

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

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

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

pub struct App {}

#[async_trait]
impl GotchaApp for App {
type State = ();

type Config = Config;

fn routes(&self, router: GotchaRouter<GotchaContext<Self::State, Self::Config>>) -> GotchaRouter<GotchaContext<Self::State, Self::Config>> {
router.get("/", hello_world)
}

async fn state(&self, _config: &ConfigWrapper<Self::Config>) -> Result<Self::State, Box<dyn std::error::Error>> {
Ok(())
}
}

#[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
async fn main() -> Result<(), Box<dyn std::error::Error>> {
App {}.run().await?;
Ok(())
}

```
2 changes: 1 addition & 1 deletion gotcha/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "gotcha"
description = "enhanced web framework based on actix-web"
edition = "2021"
version = "0.2.1"
version = "0.2.2"
license = "MIT"
repository = "https://github.com/Kilerd/gotcha/"

Expand Down

0 comments on commit 29e8127

Please sign in to comment.