Skip to content

Commit

Permalink
provide a fallback IP of 0.0.0.0 if it's missing
Browse files Browse the repository at this point in the history
  • Loading branch information
indirect committed Feb 8, 2022
1 parent af07cce commit 658c0bb
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/request.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
use std::borrow::Cow;

fn default_ip<'a>() -> Cow<'a, str> {
return Cow::from("0.0.0.0")
}

#[derive(Deserialize, Debug)]
pub struct Request<'a> {
#[serde(borrow)]
pub timestamp: Cow<'a, str>,
// time_elapsed: u8,
#[serde(borrow)]
#[serde(default="default_ip")]
pub client_ip: Cow<'a, str>,
// client_continent: String,
// client_country: String,
Expand Down

0 comments on commit 658c0bb

Please sign in to comment.