Improve protobuf support (#2513)

Summary:
* Update protobuf library to support map types
* Improved usage messaging in UI
* Always attempt to decode requests with a protobuf definition
## Changelog
Improved protobuf support

Pull Request resolved: https://github.com/facebook/flipper/pull/2513

Reviewed By: mweststrate

Differential Revision: D30162379

Pulled By: passy

fbshipit-source-id: 201fb06045822641be5840b121da180a201be974
This commit is contained in:
Harold Martin
2021-08-09 02:41:13 -07:00
committed by Facebook GitHub Bot
parent 410445a1ed
commit efd75ea435
3 changed files with 21 additions and 5 deletions

View File

@@ -670,7 +670,11 @@ class ProtobufFormatter {
formatRequest(request: Request) {
if (
getHeaderValue(request.requestHeaders, 'content-type') ===
'application/x-protobuf'
'application/x-protobuf' ||
this.protobufDefinitionRepository.hasDefinition(
request.method,
request.url,
)
) {
const protobufDefinition =
this.protobufDefinitionRepository.getRequestType(
@@ -681,7 +685,9 @@ class ProtobufFormatter {
return (
<Text>
Could not locate protobuf definition for request body of{' '}
{request.url}
{request.url} <br />
Please send ProtobufJS definitions with the plugin's
addProtobufDefinitions method.
</Text>
);
}
@@ -704,7 +710,11 @@ class ProtobufFormatter {
if (
getHeaderValue(request.responseHeaders, 'content-type') ===
'application/x-protobuf' ||
request.url.endsWith('.proto')
request.url.endsWith('.proto') ||
this.protobufDefinitionRepository.hasDefinition(
request.method,
request.url,
)
) {
const protobufDefinition =
this.protobufDefinitionRepository.getResponseType(
@@ -715,7 +725,9 @@ class ProtobufFormatter {
return (
<Text>
Could not locate protobuf definition for response body of{' '}
{request.url}
{request.url} <br />
Please send ProtobufJS definitions with the plugin's
addProtobufDefinitions method.
</Text>
);
}