fixed hostname and version fields in /api/0/info#58
Merged
Conversation
johan-bjareholt
approved these changes
Aug 22, 2019
Member
johan-bjareholt
left a comment
There was a problem hiding this comment.
Had forgotten completely about this, thanks!
| log = "0.4" | ||
| fern = { version = "0.5", features = ["colored"] } | ||
| toml = "0.5" | ||
| gethostname = "0.2" |
Member
There was a problem hiding this comment.
Only depends on libc and winapi, nice!
johan-bjareholt
requested changes
Aug 22, 2019
| } | ||
|
|
||
| let hostname = gethostname().into_string().unwrap_or("unknown".to_string()); | ||
| const VERSION: &'static str = env!("CARGO_PKG_VERSION"); |
Member
There was a problem hiding this comment.
Wait, does this really work when not running with "cargo run"?
Member
Author
There was a problem hiding this comment.
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?
Member
Author
There was a problem hiding this comment.
Member
Author
There was a problem hiding this comment.
Apparently env! fetches the variable at compile-time: https://doc.rust-lang.org/std/macro.env.html
This was referenced Jan 1, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.