Class GrpcHandlerFactory
- All Implemented Interfaces:
HTTPRequestHandlerFactory
Checks that the path matches /package.Service/Method and content-type is application/grpc, then returns a handler that parses gRPC framing and dispatches to the GrpcService.
- Author:
- Chris Burdess
-
Constructor Summary
ConstructorsConstructorDescriptionGrpcHandlerFactory(ProtoFile protoFile, GrpcService service) Creates a factory with the given Proto model and service. -
Method Summary
Modifier and TypeMethodDescriptioncreateHandler(HTTPResponseState state, Headers headers) Creates a handler for a new request.Returns the set of HTTP methods supported by this factory.
-
Constructor Details
-
GrpcHandlerFactory
Creates a factory with the given Proto model and service.- Parameters:
protoFile- the Proto modelservice- the gRPC service implementation
-
-
Method Details
-
createHandler
Description copied from interface:HTTPRequestHandlerFactoryCreates a handler for a new request.Called when the initial headers for a stream are received. The factory can examine the headers to decide which handler implementation to return.
The returned handler will receive a
HTTPRequestHandler.headers(org.bluezoo.gumdrop.http.HTTPResponseState, org.bluezoo.gumdrop.http.Headers)callback with the same headers - the factory is for routing/creation, the handler performs the actual request processing.- Specified by:
createHandlerin interfaceHTTPRequestHandlerFactory- Parameters:
state- the response state for this stream (can be used to send early responses like 401)headers- the initial request headers (includes :method, :path, :scheme, :authority pseudo-headers)- Returns:
- a handler for this request, or null to reject (sends 404 if no response was sent via state)
-
getSupportedMethods
Description copied from interface:HTTPRequestHandlerFactoryReturns the set of HTTP methods supported by this factory.Override this method to add custom methods (e.g., WebDAV methods like PROPFIND, PROPPATCH, MKCOL, COPY, MOVE, LOCK, UNLOCK) or to restrict the methods that are accepted.
If this method returns null (the default), the connection uses its default set of known methods:
- Standard HTTP: GET, HEAD, POST, PUT, DELETE, CONNECT, OPTIONS, TRACE, PATCH
- HTTP/2: PRI
- WebDAV: PROPFIND, PROPPATCH, MKCOL, COPY, MOVE, LOCK, UNLOCK
Unknown methods result in a 501 Not Implemented response.
- Specified by:
getSupportedMethodsin interfaceHTTPRequestHandlerFactory- Returns:
- set of supported method names (uppercase), or null to use defaults
-