Skip to content
Merged
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
13 changes: 12 additions & 1 deletion serving/samples/helloworld-rust/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(|_| {
Expand Down
12 changes: 11 additions & 1 deletion serving/samples/helloworld-rust/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(|_| {
Expand Down