Skip to content

fixed hostname and version fields in /api/0/info#58

Merged
ErikBjare merged 2 commits intomasterfrom
dev/fixed-hostname-and-version
Aug 23, 2019
Merged

fixed hostname and version fields in /api/0/info#58
ErikBjare merged 2 commits intomasterfrom
dev/fixed-hostname-and-version

Conversation

@ErikBjare
Copy link
Copy Markdown
Member

No description provided.

Copy link
Copy Markdown
Member

@johan-bjareholt johan-bjareholt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had forgotten completely about this, thanks!

Comment thread Cargo.toml
log = "0.4"
fern = { version = "0.5", features = ["colored"] }
toml = "0.5"
gethostname = "0.2"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only depends on libc and winapi, nice!

Comment thread src/endpoints/mod.rs Outdated
}

let hostname = gethostname().into_string().unwrap_or("unknown".to_string());
const VERSION: &'static str = env!("CARGO_PKG_VERSION");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait, does this really work when not running with "cargo run"?

Copy link
Copy Markdown
Member Author

@ErikBjare ErikBjare Aug 22, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The following worked:

$ cargo build
...
$ ./target/debug/aw-server-rust
...
$ curl localhost:5667/api/0/info
{"hostname":"erb-laptop2-arch","testing":true,"version":"aw-server-rust v0.1.0"}

I think as long as you build with cargo it'll work fine?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apparently env! fetches the variable at compile-time: https://doc.rust-lang.org/std/macro.env.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants