Skip to content

Commit

Permalink
Rust/may_minihttp improve update (#7908)
Browse files Browse the repository at this point in the history
  • Loading branch information
Xudong-Huang authored Nov 2, 2024
1 parent 2fced47 commit 96f3a00
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
11 changes: 10 additions & 1 deletion rust/may_minihttp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,13 @@ version = "0.0.0"
edition = "2021"

[dependencies]
may_minihttp = "0.1"
may_minihttp = { version = "0.1", default-features = false }

[profile.release]
opt-level = 3
codegen-units = 1
panic = 'abort'
lto = 'thin'
debug = false
incremental = false
overflow-checks = false
5 changes: 1 addition & 4 deletions rust/may_minihttp/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,11 @@ impl HttpService for WebFramework {
("GET", "/") => {
rsp.header("Content-Type: text/plain");
}

(method_, path_) if path_.starts_with("/user") => {
if method_ == "GET" {
let id = path_.split("/").last().unwrap();
rsp.header("Content-Type: text/plain");

let body_response = format!("{}", id);
rsp.body_mut().extend_from_slice(body_response.as_bytes());
rsp.body_mut().extend_from_slice(id.as_bytes());
} else if method_ == "POST" {
rsp.status_code(200, "OK");
}
Expand Down

0 comments on commit 96f3a00

Please sign in to comment.