mirror of https://github.com/knative/docs.git
serving/helloworld-rust: respect the PORT env var (#464)
This commit is contained in:
parent
070c88b24a
commit
dbdf3c922c
|
@ -2,6 +2,7 @@
|
|||
|
||||
A simple web app written in Rust that you can use for testing.
|
||||
It reads in an env variable `TARGET` and prints "Hello ${TARGET}!". If
|
||||
|
||||
TARGET is not specified, it will use "World" as the TARGET.
|
||||
|
||||
## Prerequisites
|
||||
|
@ -48,7 +49,17 @@ following instructions recreate the source files from this folder.
|
|||
fn main() {
|
||||
pretty_env_logger::init();
|
||||
|
||||
let addr = ([0, 0, 0, 0], 8080).into();
|
||||
let mut port: u16 = 8080;
|
||||
match env::var("PORT") {
|
||||
Ok(p) => {
|
||||
match p.parse::<u16>() {
|
||||
Ok(n) => {port = n;},
|
||||
Err(_e) => {},
|
||||
};
|
||||
}
|
||||
Err(_e) => {},
|
||||
};
|
||||
let addr = ([0, 0, 0, 0], port).into();
|
||||
|
||||
let new_service = || {
|
||||
service_fn_ok(|_| {
|
||||
|
|
|
@ -10,7 +10,17 @@ use std::env;
|
|||
fn main() {
|
||||
pretty_env_logger::init();
|
||||
|
||||
let addr = ([0, 0, 0, 0], 8080).into();
|
||||
let mut port: u16 = 8080;
|
||||
match env::var("PORT") {
|
||||
Ok(p) => {
|
||||
match p.parse::<u16>() {
|
||||
Ok(n) => {port = n;},
|
||||
Err(_e) => {},
|
||||
};
|
||||
}
|
||||
Err(_e) => {},
|
||||
};
|
||||
let addr = ([0, 0, 0, 0], port).into();
|
||||
|
||||
let new_service = || {
|
||||
service_fn_ok(|_| {
|
||||
|
|
Loading…
Reference in New Issue