From bd6ebb32df11641e148fd0adca41e7188f16afce Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Mon, 15 Jul 2019 14:00:27 -0400 Subject: hyper_hello should be in its own crate (#2641) So that "cargo build" will build it when the gn frontend is eventually removed. --- tools/hyper_hello.rs | 39 --------------------------------------- tools/hyper_hello/Cargo.toml | 11 +++++++++++ tools/hyper_hello/hyper_hello.rs | 39 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 50 insertions(+), 39 deletions(-) delete mode 100644 tools/hyper_hello.rs create mode 100644 tools/hyper_hello/Cargo.toml create mode 100644 tools/hyper_hello/hyper_hello.rs (limited to 'tools') diff --git a/tools/hyper_hello.rs b/tools/hyper_hello.rs deleted file mode 100644 index dc4dceb06..000000000 --- a/tools/hyper_hello.rs +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. -// Adapted from https://github.com/hyperium/hyper/blob/master/examples/hello.rs - -#![deny(warnings)] -extern crate hyper; - -use hyper::rt::{self, Future}; -use hyper::service::service_fn_ok; -use hyper::{Body, Response, Server}; -use std::env; - -static PHRASE: &'static [u8] = b"Hello World!"; - -fn main() { - let mut port: u16 = 4544; - if let Some(custom_port) = env::args().nth(1) { - port = custom_port.parse::().unwrap(); - } - - let addr = ([127, 0, 0, 1], port).into(); - - // new_service is run for each connection, creating a 'service' - // to handle requests for that specific connection. - let new_service = || { - // This is the `Service` that will handle the connection. - // `service_fn_ok` is a helper to convert a function that - // returns a Response into a `Service`. - service_fn_ok(|_| Response::new(Body::from(PHRASE))) - }; - - let server = Server::bind(&addr) - .tcp_nodelay(true) - .serve(new_service) - .map_err(|e| eprintln!("server error: {}", e)); - - println!("Listening on http://{}", addr); - - rt::run(server); -} diff --git a/tools/hyper_hello/Cargo.toml b/tools/hyper_hello/Cargo.toml new file mode 100644 index 000000000..44226a143 --- /dev/null +++ b/tools/hyper_hello/Cargo.toml @@ -0,0 +1,11 @@ +[package] +name = "hyper_hello" +version = "0.0.1" + +[dependencies] +hyper = "0.12.30" +ring = "0.14.6" + +[[bin]] +name = "hyper_hello" +path = "hyper_hello.rs" diff --git a/tools/hyper_hello/hyper_hello.rs b/tools/hyper_hello/hyper_hello.rs new file mode 100644 index 000000000..dc4dceb06 --- /dev/null +++ b/tools/hyper_hello/hyper_hello.rs @@ -0,0 +1,39 @@ +// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. +// Adapted from https://github.com/hyperium/hyper/blob/master/examples/hello.rs + +#![deny(warnings)] +extern crate hyper; + +use hyper::rt::{self, Future}; +use hyper::service::service_fn_ok; +use hyper::{Body, Response, Server}; +use std::env; + +static PHRASE: &'static [u8] = b"Hello World!"; + +fn main() { + let mut port: u16 = 4544; + if let Some(custom_port) = env::args().nth(1) { + port = custom_port.parse::().unwrap(); + } + + let addr = ([127, 0, 0, 1], port).into(); + + // new_service is run for each connection, creating a 'service' + // to handle requests for that specific connection. + let new_service = || { + // This is the `Service` that will handle the connection. + // `service_fn_ok` is a helper to convert a function that + // returns a Response into a `Service`. + service_fn_ok(|_| Response::new(Body::from(PHRASE))) + }; + + let server = Server::bind(&addr) + .tcp_nodelay(true) + .serve(new_service) + .map_err(|e| eprintln!("server error: {}", e)); + + println!("Listening on http://{}", addr); + + rt::run(server); +} -- cgit v1.2.3