Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rust/may_minihttp improve update #7908

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion rust/may_minihttp/Cargo.toml
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding options. I didn't check when PR was made. Could you take the same options for all rust frameworks?

I mean, it is important to have meaningful results to have the same compilation options, and ofc options that are safe to deploy in production

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]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we use this as command line arguments ?

Copy link
Author

@Xudong-Huang Xudong-Huang Nov 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

other rust frame work also use this value

[profile.release]
opt-level = 3
debug = false
debug-assertions = false
lto = true
panic = "abort"
incremental = false
codegen-units = 1
rpath = false
strip = false

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
Loading