Skip to content

Commit

Permalink
Hubertshelley patch 1 (#6385)
Browse files Browse the repository at this point in the history
* [Silent] add Silent

* [Silent] add Silent

* Update ci.yml

* Update ci.yml
  • Loading branch information
hubertshelley committed May 23, 2023
1 parent 54f587a commit d4b21b0
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 0 deletions.
2 changes: 2 additions & 0 deletions reviewers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,8 @@ rust:
- colinbankier
salvo:
- chrislearn
silent:
- hubertshelley
poem:
- sunli829
axum:
Expand Down
21 changes: 21 additions & 0 deletions rust/silent/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[package]
name = "server"
version = "0.0.0"
edition = "2021"
authors = ["Hubert Shelley <hubertshelley@163.com>"]

[dependencies]
async-trait = "0.1.68"
silent = { version = "0.6" }

[profile.release]
opt-level = 3
debug = false
debug-assertions = false
overflow-checks = false
lto = true
panic = "abort"
incremental = false
codegen-units = 1
rpath = false
strip = false
3 changes: 3 additions & 0 deletions rust/silent/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
framework:
github: hubertshelley/silent
version: "0.6"
35 changes: 35 additions & 0 deletions rust/silent/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
use std::sync::Arc;
use async_trait::async_trait;
use silent::prelude::*;

struct Index;

#[async_trait]
impl Handler for Index {
async fn call(&self, _req: Request) -> Result<Response> {
Ok(Response::empty())
}
}

fn main() {
let mut user_route = Route::new("user").append(
Route::new("<id>").get(
|req| async move {
req.get_path_params::<String>("id")
}
),
);
user_route.get_handler_mut().insert(
Method::POST,
Arc::new(Index),
);
let mut route = Route::new("")
.append(
user_route
);
route.get_handler_mut().insert(
Method::GET,
Arc::new(Index),
);
Server::new().bind("0.0.0.0:3000".parse().unwrap()).bind_route(route).run();
}

0 comments on commit d4b21b0

Please sign in to comment.