fullstorydev / grpcui

An interactive web UI for gRPC, along the lines of postman
MIT License
5.24k stars 388 forks source link

-default-header would be clear when using -examples at the same time #237

Closed jtsai-dev closed 1 year ago

jtsai-dev commented 1 year ago

i have been develop some grpc API which most of them need to be auth when requesting as set the token for header with Authorization:Bearer xxx. And i written some examples for request, start the grpcui with command

grpcui -default-header 'Authorization:Bearer xxx' -examples '\examples\request.json' -plaintext localhost:3010

the content of request.json almost as follows

[{
    "name": "Apply",
    "service": "xxxService",
    "method": "Apply",
    "request": {
      "data": {
        "Id": "1",
        "Email": "a@example.com"
      }
    }
  }
  ...
]

when i choose the [Apply] in grpcui's webForm, the default header will be clear, i knew it could be set 'Metadata' in json file, but when the token expired for security reasons, i need to rewrite all the metadata in json file, that is so terrible. so, are there any way to set -default-header as default if it is empty in json file, so i can rewrite it only once in start command?

jhump commented 1 year ago

@yyeiei, checkout the -H and -rpc-header arguments. These are always supplied to the server, not shown in the UI, and cannot be overridden. They are perfect for things like credentials. This was added just over a year ago in v1.3.0.

See #163 for more details about these flags and others newly added at the same time.

jtsai-dev commented 1 year ago

I had tried to use -H instead of -default-header, and it solved my problem! I will close this issue.

By the way, there is an exception when using examples: it will be undefined without setting in json file. I created a pull request, you can just review it #238