Skip to content

Commit

Permalink
Support custom endpoints [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
50U10FCA7 committed Nov 27, 2024
1 parent b0eb7d5 commit 712f175
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use hyper_rustls::{ConfigBuilderExt, HttpsConnector, HttpsConnectorBuilder};
use hyper_util::client::legacy::connect::HttpConnector;
use hyper_util::client::legacy::Client as HttpClient;
use hyper_util::rt::TokioExecutor;
use std::borrow::Cow;
use std::convert::Infallible;
use std::io::Read;
use std::time::Duration;
Expand All @@ -28,6 +29,8 @@ type HyperConnector = HttpsConnector<HttpConnector>;
/// The APNs service endpoint to connect.
#[derive(Debug, Clone)]
pub enum Endpoint {
/// Custom endpoint.
Custom(Cow<'static, str>),
/// The production environment (api.push.apple.com)
Production,
/// The development/test environment (api.development.push.apple.com)
Expand All @@ -37,11 +40,12 @@ pub enum Endpoint {
impl fmt::Display for Endpoint {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let host = match self {
Endpoint::Custom(host) => host.as_ref(),
Endpoint::Production => "api.push.apple.com",
Endpoint::Sandbox => "api.development.push.apple.com",
};

write!(f, "{}", host)
write!(f, "{host}")
}
}

Expand Down

0 comments on commit 712f175

Please sign in to comment.