Skip to content

Commit a1a3785

Browse files
committed
feat: Nexa로 프로필 이미지 데이터 요청
1 parent d5c3dcc commit a1a3785

2 files changed

Lines changed: 39 additions & 0 deletions

File tree

Application/DevLogInfra/Sources/InfraAssembler.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ public final class InfraAssembler: Assembler {
6161
UserServiceImpl()
6262
}
6363

64+
container.register(ProfileImageDataService.self) {
65+
ProfileImageDataServiceImpl()
66+
}
67+
6468
container.register(PushNotificationService.self) {
6569
PushNotificationServiceImpl()
6670
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
//
2+
// ProfileImageDataServiceImpl.swift
3+
// DevLogInfra
4+
//
5+
// Created by opfic on 6/11/26.
6+
//
7+
8+
import Foundation
9+
import Nexa
10+
import DevLogData
11+
12+
final class ProfileImageDataServiceImpl: ProfileImageDataService {
13+
func fetchImageData(from url: URL) async throws -> Data {
14+
try await NXAPIClient(
15+
configuration: NXClientConfiguration(baseURL: url)
16+
)
17+
.get(url.absoluteString)
18+
.timeout(10)
19+
.intercept(ProfileImageDataCachePolicyInterceptor())
20+
.validate(.successStatusCode)
21+
.raw()
22+
.data
23+
}
24+
}
25+
26+
private struct ProfileImageDataCachePolicyInterceptor: NXHTTPInterceptor {
27+
func intercept(
28+
context: NXRequestExecutionContext,
29+
next: @escaping @Sendable (NXRequestExecutionContext) async throws -> NXRawResponse
30+
) async throws -> NXRawResponse {
31+
var request = context.request
32+
request.cachePolicy = .reloadIgnoringLocalCacheData
33+
return try await next(context.replacingRequest(request))
34+
}
35+
}

0 commit comments

Comments
 (0)