feat(reflection): Add dummy implementation for extension (#1209)

This commit is contained in:
tottoto
2022-12-22 10:49:51 -05:00
committed by GitHub
parent a562a3ce32
commit fdff11115b
+7 -3
View File
@@ -2,8 +2,8 @@ use crate::proto::server_reflection_request::MessageRequest;
use crate::proto::server_reflection_response::MessageResponse; use crate::proto::server_reflection_response::MessageResponse;
pub use crate::proto::server_reflection_server::{ServerReflection, ServerReflectionServer}; pub use crate::proto::server_reflection_server::{ServerReflection, ServerReflectionServer};
use crate::proto::{ use crate::proto::{
FileDescriptorResponse, ListServiceResponse, ServerReflectionRequest, ServerReflectionResponse, ExtensionNumberResponse, FileDescriptorResponse, ListServiceResponse, ServerReflectionRequest,
ServiceResponse, ServerReflectionResponse, ServiceResponse,
}; };
use prost::{DecodeError, Message}; use prost::{DecodeError, Message};
use prost_types::{ use prost_types::{
@@ -347,7 +347,11 @@ impl ServerReflection for ReflectionService {
Err(Status::not_found("extensions are not supported")) Err(Status::not_found("extensions are not supported"))
} }
MessageRequest::AllExtensionNumbersOfType(_) => { MessageRequest::AllExtensionNumbersOfType(_) => {
Err(Status::not_found("extensions are not supported")) // NOTE: Workaround. Some grpc clients (e.g. grpcurl) expect this method not to fail.
// https://github.com/hyperium/tonic/issues/1077
Ok(MessageResponse::AllExtensionNumbersResponse(
ExtensionNumberResponse::default(),
))
} }
MessageRequest::ListServices(_) => Ok(state.list_services()), MessageRequest::ListServices(_) => Ok(state.list_services()),
}, },