config: add UUID validation
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
This commit is contained in:
parent
f343ff783b
commit
f0dff60d74
|
@ -8,3 +8,4 @@ edition = "2018"
|
|||
|
||||
[dependencies]
|
||||
ureq = "1.1.1"
|
||||
uuid = { version = "0.8.1", default-features = false, features = [ "v1" ] }
|
||||
|
|
|
@ -1,9 +1,15 @@
|
|||
use uuid::Uuid;
|
||||
|
||||
pub struct HealthcheckConfig {
|
||||
pub uuid: String,
|
||||
}
|
||||
|
||||
pub fn create_config(uuid: &str) -> HealthcheckConfig {
|
||||
HealthcheckConfig {
|
||||
uuid: uuid.to_string(),
|
||||
if let Ok(_) = Uuid::parse_str(uuid) {
|
||||
HealthcheckConfig {
|
||||
uuid: uuid.to_string(),
|
||||
}
|
||||
} else {
|
||||
panic!("Invalid UUID: {}", uuid)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue