-
-
Save erikdesjardins/0d3d19194c85fdf3557d9955fd54f605 to your computer and use it in GitHub Desktop.
old hyper str comparison benchmark
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[package] | |
name = "hyper-test" | |
version = "0.1.0" | |
authors = [] | |
edition = "2018" | |
[dependencies] | |
hyper = { version = "=0.9.4", default-features = false } | |
[features] | |
enum = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use hyper::Server; | |
use hyper::method::Method; | |
use hyper::server::Request; | |
use hyper::server::Response; | |
#[cfg(not(feature = "enum"))] | |
fn hello(req: Request, res: Response) { | |
if req.method.as_ref() == "GET" { | |
res.send(b"Hello World!").unwrap(); | |
} else { | |
panic!("only can handle GET") | |
} | |
} | |
#[cfg(feature = "enum")] | |
fn hello(req: Request, res: Response) { | |
if req.method == Method::Get { | |
res.send(b"Hello World!").unwrap(); | |
} else { | |
panic!("only can handle GET") | |
} | |
} | |
fn main() { | |
Server::http("127.0.0.1:3000").unwrap() | |
.handle(hello).unwrap(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment