Skip to content

Commit

Permalink
Add downloadContentHost for download style request in DBTransportBase…
Browse files Browse the repository at this point in the history
…HostnameConfig (#381)
  • Loading branch information
jamesyangf committed May 16, 2024
1 parent 1dd6694 commit de63d14
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, readonly, copy) NSString *meta;
@property (nonatomic, readonly, copy) NSString *api;
@property (nonatomic, readonly, copy) NSString *content;
@property (nonatomic, readonly, copy) NSString *downloadContent;
@property (nonatomic, readonly, copy) NSString *notify;

///
Expand All @@ -45,11 +46,12 @@ NS_ASSUME_NONNULL_BEGIN
/// @param meta the hostname to metaserver
/// @param api the hostname to api server
/// @param content the hostname to content server
/// @param downloadContent the hostname to content server for download style
/// @param notify the hostname to notify server
///
/// @return An initialized instance with the provided hostname configuration
///
- (instancetype)initWithMeta:(NSString *)meta api:(NSString *)api content:(NSString *)content notify:(NSString *)notify;
- (instancetype)initWithMeta:(NSString *)meta api:(NSString *)api content:(NSString *)content downloadContent:(NSString *)downloadContent notify:(NSString *)notify;

///
/// Returns the prefix to use for API calls to the given route type.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,32 @@ - (instancetype)initWithMeta:(NSString *)meta
_meta = meta;
_api = api;
_content = content;
_downloadContent = content;
_notify = notify;
}
return self;
}

- (instancetype)initWithMeta:(NSString *)meta
api:(NSString *)api
content:(NSString *)content
downloadContent:(NSString *)downloadContent
notify:(NSString *)notify {
self = [self initWithMeta:meta api:api content:content notify:notify];
_downloadContent = downloadContent;
return self;
}

- (nullable NSString *)apiV2PrefixWithRoute:(DBRoute *)route {
switch (route.host) {
case DBRouteHostApi:
return [NSString stringWithFormat:@"https://%@/2", _api];
case DBRouteHostContent:
return [NSString stringWithFormat:@"https://%@/2", _content];
if ([route.attrs[@"style"] isEqualToString:@"download"]) {
return [NSString stringWithFormat:@"https://%@/2", _downloadContent];
} else {
return [NSString stringWithFormat:@"https://%@/2", _content];
}
case DBRouteHostNotify:
return [NSString stringWithFormat:@"https://%@/2", _notify];
case DBRouteHostUnknown:
Expand Down

0 comments on commit de63d14

Please sign in to comment.