GRPCMiddleware
public class GRPCMiddleware : Middleware
A GRPCMiddleware instance can be integrated as a middleware into the Vapor application like this:
app.middleware.use(GRPCMiddleware())
This middleware checks the content-type of incoming requests and in handles them in case of a gRPC request or forwards them to the next middleware.
It implements Vapor’s Moiddleware protocol which requires it to implement a respondfunction.
-
Initializes a
GRPCMiddlewareusing theGRPCServicespassed as an argument.Declaration
Swift
public init(services: [GRPCService] = [])Parameters
servicesGRPCServiceinstances that should be included for routing.
-
Adds
GRPCServiceinstance to theservicesdictionary.Declaration
Swift
public func addService(_ service: GRPCService)Parameters
serviceGRPCServiceinstance that should be used by the middleware. -
Handles to incoming Vapor
Requests and responds with anEventLoopFutureof a VaporResponse.This method starts out by checking if the incoming request can be handeled by this middleware or should be forwarded to the next responder. It can handle the incoming request if its content-type is
application/grpcand thegetCallHandlermethod returns a call handler. If this middleware can handle the request it returns theresponseof the call handler which is of typeEventLoopFuture<Response>.Declaration
Swift
public func respond(to request: Request, chainingTo next: Responder) -> EventLoopFuture<Response>Parameters
requestIncoming Vapor
Requestinstance that should be handled.nextResponderinstance that either is the next middleware or the Vapor router. This one is used if the incoming request can’t be handled by this middleware.Return Value
An
EventLoopFutureof a VaporResponsethat will be sent to the client by the Vapor stack.
View on GitHub
GRPCMiddleware Class Reference