Skip to content

Commit

Permalink
Merge pull request #173 from sr-gi/endpoints
Browse files Browse the repository at this point in the history
Defines Endpoint enum to avoid using hardcoded strings as endpoints
  • Loading branch information
sr-gi authored Jan 20, 2023
2 parents 19b3ad8 + 44df8bb commit b035a3e
Show file tree
Hide file tree
Showing 6 changed files with 142 additions and 79 deletions.
27 changes: 27 additions & 0 deletions teos-common/src/net/http.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
pub enum Endpoint {
Register,
AddAppointment,
GetAppointment,
GetSubscriptionInfo,
}

impl std::fmt::Display for Endpoint {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
write!(
f,
"{}",
match self {
Endpoint::Register => "register",
Endpoint::AddAppointment => "add_appointment",
Endpoint::GetAppointment => "get_appointment",
Endpoint::GetSubscriptionInfo => "get_subscription_info",
}
)
}
}

impl Endpoint {
pub fn path(&self) -> String {
format!("/{}", self)
}
}
2 changes: 2 additions & 0 deletions teos-common/src/net.rs → teos-common/src/net/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
pub mod http;

use serde::Serialize;
use std::fmt;

Expand Down
Loading

0 comments on commit b035a3e

Please sign in to comment.