-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bcbc900
commit 558545c
Showing
3 changed files
with
70 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
Fyreplace/Sources/gRPC/RequestIdentificationInterceptor.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import Foundation | ||
import GRPC | ||
import NIOCore | ||
|
||
class RequestIdentificationInterceptor<Request, Response>: ClientInterceptor<Request, Response> { | ||
override func send(_ part: GRPCClientRequestPart<Request>, promise: EventLoopPromise<Void>?, context: ClientInterceptorContext<Request, Response>) { | ||
if case var GRPCClientRequestPart.metadata(headers) = part { | ||
headers.add(name: "x-request-id", value: UUID().uuidString) | ||
super.send(.metadata(headers), promise: promise, context: context) | ||
} else { | ||
super.send(part, promise: promise, context: context) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,206 +1,210 @@ | ||
import GRPC | ||
import SwiftProtobuf | ||
|
||
func makeInterceptors<Request, Response>() -> [ClientInterceptor<Request, Response>] { | ||
return [RequestIdentificationInterceptor(), AuthenticationInterceptor()] | ||
} | ||
|
||
struct AccountServiceClientInterceptorFactory: FPAccountServiceClientInterceptorFactoryProtocol { | ||
func makeCreateInterceptors() -> [ClientInterceptor<FPUserCreation, Google_Protobuf_Empty>] { | ||
return [AuthenticationInterceptor<FPUserCreation, Google_Protobuf_Empty>()] | ||
return makeInterceptors() | ||
} | ||
|
||
func makeDeleteInterceptors() -> [ClientInterceptor<Google_Protobuf_Empty, Google_Protobuf_Empty>] { | ||
return [AuthenticationInterceptor<Google_Protobuf_Empty, Google_Protobuf_Empty>()] | ||
return makeInterceptors() | ||
} | ||
|
||
func makeSendActivationEmailInterceptors() -> [ClientInterceptor<FPEmail, Google_Protobuf_Empty>] { | ||
return [AuthenticationInterceptor<FPEmail, Google_Protobuf_Empty>()] | ||
return makeInterceptors() | ||
} | ||
|
||
func makeConfirmActivationInterceptors() -> [ClientInterceptor<FPConnectionToken, FPToken>] { | ||
return [AuthenticationInterceptor<FPConnectionToken, FPToken>()] | ||
return makeInterceptors() | ||
} | ||
|
||
func makeListConnectionsInterceptors() -> [ClientInterceptor<Google_Protobuf_Empty, FPConnections>] { | ||
return [AuthenticationInterceptor<Google_Protobuf_Empty, FPConnections>()] | ||
return makeInterceptors() | ||
} | ||
|
||
func makeSendConnectionEmailInterceptors() -> [ClientInterceptor<FPEmail, Google_Protobuf_Empty>] { | ||
return [AuthenticationInterceptor<FPEmail, Google_Protobuf_Empty>()] | ||
return makeInterceptors() | ||
} | ||
|
||
func makeConfirmConnectionInterceptors() -> [ClientInterceptor<FPConnectionToken, FPToken>] { | ||
return [AuthenticationInterceptor<FPConnectionToken, FPToken>()] | ||
return makeInterceptors() | ||
} | ||
|
||
func makeConnectInterceptors() -> [ClientInterceptor<FPConnectionCredentials, FPToken>] { | ||
return [AuthenticationInterceptor<FPConnectionCredentials, FPToken>()] | ||
return makeInterceptors() | ||
} | ||
|
||
func makeDisconnectInterceptors() -> [ClientInterceptor<FPId, Google_Protobuf_Empty>] { | ||
return [AuthenticationInterceptor<FPId, Google_Protobuf_Empty>()] | ||
return makeInterceptors() | ||
} | ||
|
||
func makeDisconnectAllInterceptors() -> [ClientInterceptor<Google_Protobuf_Empty, Google_Protobuf_Empty>] { | ||
return [AuthenticationInterceptor<Google_Protobuf_Empty, Google_Protobuf_Empty>()] | ||
return makeInterceptors() | ||
} | ||
} | ||
|
||
struct UserServiceClientInterceptorFactory: FPUserServiceClientInterceptorFactoryProtocol { | ||
func makeRetrieveInterceptors() -> [ClientInterceptor<FPId, FPUser>] { | ||
return [AuthenticationInterceptor<FPId, FPUser>()] | ||
return makeInterceptors() | ||
} | ||
|
||
func makeRetrieveMeInterceptors() -> [ClientInterceptor<Google_Protobuf_Empty, FPUser>] { | ||
return [AuthenticationInterceptor<Google_Protobuf_Empty, FPUser>()] | ||
return makeInterceptors() | ||
} | ||
|
||
func makeUpdateAvatarInterceptors() -> [ClientInterceptor<FPImageChunk, FPImage>] { | ||
return [AuthenticationInterceptor<FPImageChunk, FPImage>()] | ||
return makeInterceptors() | ||
} | ||
|
||
func makeUpdateBioInterceptors() -> [ClientInterceptor<FPBio, Google_Protobuf_Empty>] { | ||
return [AuthenticationInterceptor<FPBio, Google_Protobuf_Empty>()] | ||
return makeInterceptors() | ||
} | ||
|
||
func makeSendEmailUpdateEmailInterceptors() -> [ClientInterceptor<FPEmail, Google_Protobuf_Empty>] { | ||
return [AuthenticationInterceptor<FPEmail, Google_Protobuf_Empty>()] | ||
return makeInterceptors() | ||
} | ||
|
||
func makeConfirmEmailUpdateInterceptors() -> [ClientInterceptor<FPToken, Google_Protobuf_Empty>] { | ||
return [AuthenticationInterceptor<FPToken, Google_Protobuf_Empty>()] | ||
return makeInterceptors() | ||
} | ||
|
||
func makeListBlockedInterceptors() -> [ClientInterceptor<FPPage, FPProfiles>] { | ||
return [AuthenticationInterceptor<FPPage, FPProfiles>()] | ||
return makeInterceptors() | ||
} | ||
|
||
func makeUpdateBlockInterceptors() -> [ClientInterceptor<FPBlock, Google_Protobuf_Empty>] { | ||
return [AuthenticationInterceptor<FPBlock, Google_Protobuf_Empty>()] | ||
return makeInterceptors() | ||
} | ||
|
||
func makeReportInterceptors() -> [ClientInterceptor<FPId, Google_Protobuf_Empty>] { | ||
return [AuthenticationInterceptor<FPId, Google_Protobuf_Empty>()] | ||
return makeInterceptors() | ||
} | ||
|
||
func makeAbsolveInterceptors() -> [ClientInterceptor<FPId, Google_Protobuf_Empty>] { | ||
return [AuthenticationInterceptor<FPId, Google_Protobuf_Empty>()] | ||
return makeInterceptors() | ||
} | ||
|
||
func makeBanInterceptors() -> [ClientInterceptor<FPBanSentence, Google_Protobuf_Empty>] { | ||
return [AuthenticationInterceptor<FPBanSentence, Google_Protobuf_Empty>()] | ||
return makeInterceptors() | ||
} | ||
|
||
func makePromoteInterceptors() -> [ClientInterceptor<FPPromotion, Google_Protobuf_Empty>] { | ||
return [AuthenticationInterceptor<FPPromotion, Google_Protobuf_Empty>()] | ||
return makeInterceptors() | ||
} | ||
} | ||
|
||
struct PostServiceClientInterceptorFactory: FPPostServiceClientInterceptorFactoryProtocol { | ||
func makeListFeedInterceptors() -> [ClientInterceptor<FPVote, FPPost>] { | ||
return [AuthenticationInterceptor<FPVote, FPPost>()] | ||
return makeInterceptors() | ||
} | ||
|
||
func makeListArchiveInterceptors() -> [ClientInterceptor<FPPage, FPPosts>] { | ||
return [AuthenticationInterceptor<FPPage, FPPosts>()] | ||
return makeInterceptors() | ||
} | ||
|
||
func makeListOwnPostsInterceptors() -> [ClientInterceptor<FPPage, FPPosts>] { | ||
return [AuthenticationInterceptor<FPPage, FPPosts>()] | ||
return makeInterceptors() | ||
} | ||
|
||
func makeListDraftsInterceptors() -> [ClientInterceptor<FPPage, FPPosts>] { | ||
return [AuthenticationInterceptor<FPPage, FPPosts>()] | ||
return makeInterceptors() | ||
} | ||
|
||
func makeRetrieveInterceptors() -> [ClientInterceptor<FPId, FPPost>] { | ||
return [AuthenticationInterceptor<FPId, FPPost>()] | ||
return makeInterceptors() | ||
} | ||
|
||
func makeCreateInterceptors() -> [ClientInterceptor<Google_Protobuf_Empty, FPId>] { | ||
return [AuthenticationInterceptor<Google_Protobuf_Empty, FPId>()] | ||
return makeInterceptors() | ||
} | ||
|
||
func makePublishInterceptors() -> [ClientInterceptor<FPPublication, Google_Protobuf_Empty>] { | ||
return [AuthenticationInterceptor<FPPublication, Google_Protobuf_Empty>()] | ||
return makeInterceptors() | ||
} | ||
|
||
func makeDeleteInterceptors() -> [ClientInterceptor<FPId, Google_Protobuf_Empty>] { | ||
return [AuthenticationInterceptor<FPId, Google_Protobuf_Empty>()] | ||
return makeInterceptors() | ||
} | ||
|
||
func makeUpdateSubscriptionInterceptors() -> [ClientInterceptor<FPSubscription, Google_Protobuf_Empty>] { | ||
return [AuthenticationInterceptor<FPSubscription, Google_Protobuf_Empty>()] | ||
return makeInterceptors() | ||
} | ||
|
||
func makeReportInterceptors() -> [ClientInterceptor<FPId, Google_Protobuf_Empty>] { | ||
return [AuthenticationInterceptor<FPId, Google_Protobuf_Empty>()] | ||
return makeInterceptors() | ||
} | ||
|
||
func makeAbsolveInterceptors() -> [ClientInterceptor<FPId, Google_Protobuf_Empty>] { | ||
return [AuthenticationInterceptor<FPId, Google_Protobuf_Empty>()] | ||
return makeInterceptors() | ||
} | ||
} | ||
|
||
struct ChapterServiceClientInterceptorFactory: FPChapterServiceClientInterceptorFactoryProtocol { | ||
func makeCreateInterceptors() -> [ClientInterceptor<FPChapterLocation, Google_Protobuf_Empty>] { | ||
return [AuthenticationInterceptor<FPChapterLocation, Google_Protobuf_Empty>()] | ||
return makeInterceptors() | ||
} | ||
|
||
func makeMoveInterceptors() -> [ClientInterceptor<FPChapterRelocation, Google_Protobuf_Empty>] { | ||
return [AuthenticationInterceptor<FPChapterRelocation, Google_Protobuf_Empty>()] | ||
return makeInterceptors() | ||
} | ||
|
||
func makeUpdateTextInterceptors() -> [ClientInterceptor<FPChapterTextUpdate, Google_Protobuf_Empty>] { | ||
return [AuthenticationInterceptor<FPChapterTextUpdate, Google_Protobuf_Empty>()] | ||
return makeInterceptors() | ||
} | ||
|
||
func makeUpdateImageInterceptors() -> [ClientInterceptor<FPChapterImageUpdate, FPImage>] { | ||
return [AuthenticationInterceptor<FPChapterImageUpdate, FPImage>()] | ||
return makeInterceptors() | ||
} | ||
|
||
func makeDeleteInterceptors() -> [ClientInterceptor<FPChapterLocation, Google_Protobuf_Empty>] { | ||
return [AuthenticationInterceptor<FPChapterLocation, Google_Protobuf_Empty>()] | ||
return makeInterceptors() | ||
} | ||
} | ||
|
||
struct CommentServiceClientInterceptorFactory: FPCommentServiceClientInterceptorFactoryProtocol { | ||
func makeListInterceptors() -> [ClientInterceptor<FPPage, FPComments>] { | ||
return [AuthenticationInterceptor<FPPage, FPComments>()] | ||
return makeInterceptors() | ||
} | ||
|
||
func makeCreateInterceptors() -> [ClientInterceptor<FPCommentCreation, FPId>] { | ||
return [AuthenticationInterceptor<FPCommentCreation, FPId>()] | ||
return makeInterceptors() | ||
} | ||
|
||
func makeDeleteInterceptors() -> [ClientInterceptor<FPId, Google_Protobuf_Empty>] { | ||
return [AuthenticationInterceptor<FPId, Google_Protobuf_Empty>()] | ||
return makeInterceptors() | ||
} | ||
|
||
func makeAcknowledgeInterceptors() -> [ClientInterceptor<FPId, Google_Protobuf_Empty>] { | ||
return [AuthenticationInterceptor<FPId, Google_Protobuf_Empty>()] | ||
return makeInterceptors() | ||
} | ||
|
||
func makeReportInterceptors() -> [ClientInterceptor<FPId, Google_Protobuf_Empty>] { | ||
return [AuthenticationInterceptor<FPId, Google_Protobuf_Empty>()] | ||
return makeInterceptors() | ||
} | ||
|
||
func makeAbsolveInterceptors() -> [ClientInterceptor<FPId, Google_Protobuf_Empty>] { | ||
return [AuthenticationInterceptor<FPId, Google_Protobuf_Empty>()] | ||
return makeInterceptors() | ||
} | ||
} | ||
|
||
struct NotificationServiceClientInterceptorFactory: FPNotificationServiceClientInterceptorFactoryProtocol { | ||
func makeCountInterceptors() -> [ClientInterceptor<Google_Protobuf_Empty, FPNotificationCount>] { | ||
return [AuthenticationInterceptor<Google_Protobuf_Empty, FPNotificationCount>()] | ||
return makeInterceptors() | ||
} | ||
|
||
func makeListInterceptors() -> [ClientInterceptor<FPPage, FPNotifications>] { | ||
return [AuthenticationInterceptor<FPPage, FPNotifications>()] | ||
return makeInterceptors() | ||
} | ||
|
||
func makeClearInterceptors() -> [ClientInterceptor<Google_Protobuf_Empty, Google_Protobuf_Empty>] { | ||
return [AuthenticationInterceptor<Google_Protobuf_Empty, Google_Protobuf_Empty>()] | ||
return makeInterceptors() | ||
} | ||
|
||
func makeRegisterTokenInterceptors() -> [ClientInterceptor<FPMessagingToken, Google_Protobuf_Empty>] { | ||
return [AuthenticationInterceptor<FPMessagingToken, Google_Protobuf_Empty>()] | ||
return makeInterceptors() | ||
} | ||
} |