mirror of
https://github.com/denoland/deno.git
synced 2025-01-03 12:58:54 -05:00
Remove tools/hyper_hello (#6651)
This commit is contained in:
parent
c7afbdaee2
commit
75d9913b22
6 changed files with 18 additions and 64 deletions
9
Cargo.lock
generated
9
Cargo.lock
generated
|
@ -956,14 +956,6 @@ dependencies = [
|
|||
"webpki",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hyper_hello"
|
||||
version = "0.0.1"
|
||||
dependencies = [
|
||||
"hyper",
|
||||
"tokio",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ident_case"
|
||||
version = "1.0.1"
|
||||
|
@ -2451,7 +2443,6 @@ dependencies = [
|
|||
"mio",
|
||||
"mio-named-pipes",
|
||||
"mio-uds",
|
||||
"num_cpus",
|
||||
"pin-project-lite",
|
||||
"signal-hook-registry",
|
||||
"slab",
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
members = [
|
||||
"cli",
|
||||
"core",
|
||||
"tools/hyper_hello",
|
||||
"deno_typescript",
|
||||
"test_plugin",
|
||||
"test_util",
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
|
||||
// Usage: provide a port as argument to run hyper_hello benchmark server
|
||||
// otherwise this starts multiple servers on many ports for test endpoints.
|
||||
|
||||
#[macro_use]
|
||||
extern crate lazy_static;
|
||||
|
@ -6,6 +8,7 @@ extern crate lazy_static;
|
|||
use futures::future::{self, FutureExt};
|
||||
use os_pipe::pipe;
|
||||
use regex::Regex;
|
||||
use std::env;
|
||||
use std::io::Read;
|
||||
use std::io::Write;
|
||||
use std::mem::replace;
|
||||
|
@ -17,8 +20,10 @@ use std::process::Stdio;
|
|||
use std::sync::Mutex;
|
||||
use std::sync::MutexGuard;
|
||||
use tempfile::TempDir;
|
||||
use warp::http::HeaderValue;
|
||||
use warp::http::Response;
|
||||
use warp::http::StatusCode;
|
||||
use warp::http::Uri;
|
||||
use warp::http::{HeaderValue, Response, StatusCode};
|
||||
use warp::hyper::Body;
|
||||
use warp::reply::with_header;
|
||||
use warp::reply::Reply;
|
||||
|
@ -78,8 +83,19 @@ pub fn test_server_path() -> PathBuf {
|
|||
p
|
||||
}
|
||||
|
||||
/// Benchmark server that just serves "hello world" responses.
|
||||
async fn hyper_hello(port: u16) {
|
||||
println!("hyper hello");
|
||||
let route = warp::any().map(|| "Hello World!");
|
||||
warp::serve(route).bind(([127, 0, 0, 1], port)).await;
|
||||
}
|
||||
|
||||
#[tokio::main]
|
||||
pub async fn run_all_servers() {
|
||||
if let Some(port) = env::args().nth(1) {
|
||||
return hyper_hello(port.parse::<u16>().unwrap()).await;
|
||||
}
|
||||
|
||||
let routes = warp::path::full().map(|path: warp::path::FullPath| {
|
||||
let p = path.as_str();
|
||||
assert_eq!(&p[0..1], "/");
|
||||
|
|
|
@ -134,7 +134,7 @@ def hyper_http(hyper_hello_exe):
|
|||
|
||||
|
||||
def http_benchmark(build_dir):
|
||||
hyper_hello_exe = os.path.join(build_dir, "hyper_hello")
|
||||
hyper_hello_exe = os.path.join(build_dir, "test_server")
|
||||
deno_core_http_bench_exe = os.path.join(build_dir,
|
||||
"examples/deno_core_http_bench")
|
||||
deno_exe = os.path.join(build_dir, "deno")
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
[package]
|
||||
name = "hyper_hello"
|
||||
version = "0.0.1"
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
hyper = "0.13.6"
|
||||
tokio = { version = "0.2.21", features = ["full"] }
|
||||
|
||||
[[bin]]
|
||||
name = "hyper_hello"
|
||||
path = "hyper_hello.rs"
|
|
@ -1,40 +0,0 @@
|
|||
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
|
||||
// Adapted from https://github.com/hyperium/hyper/blob/master/examples/hello.rs
|
||||
|
||||
#![deny(warnings)]
|
||||
|
||||
use std::convert::Infallible;
|
||||
use std::env;
|
||||
use std::error::Error;
|
||||
|
||||
use hyper::service::{make_service_fn, service_fn};
|
||||
use hyper::{Body, Response, Server};
|
||||
|
||||
type Just<T> = Result<T, Infallible>;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<(), Box<dyn Error>> {
|
||||
let mut port: u16 = 4544;
|
||||
if let Some(custom_port) = env::args().nth(1) {
|
||||
port = custom_port.parse::<u16>().unwrap();
|
||||
}
|
||||
|
||||
let addr = ([127, 0, 0, 1], port).into();
|
||||
|
||||
// For every connection, we must make a `Service` to handle all
|
||||
// incoming HTTP requests on said connection.
|
||||
let new_service = make_service_fn(|_| {
|
||||
// This is the `Service` that will handle the connection.
|
||||
// `service_fn` is a helper to convert a function that
|
||||
// returns a Response into a `Service`.
|
||||
async {
|
||||
Just::Ok(service_fn(|_req| async {
|
||||
Just::Ok(Response::new(Body::from(&b"Hello World!"[..])))
|
||||
}))
|
||||
}
|
||||
});
|
||||
|
||||
let server = Server::bind(&addr).tcp_nodelay(true).serve(new_service);
|
||||
println!("Listening on http://{}", addr);
|
||||
Ok(server.await?)
|
||||
}
|
Loading…
Reference in a new issue