refactor HeaderParser to make implementation of formatters easier/saner
#4,221 建立於 2018年8月21日
倉庫指標
- Star
- (27,997 star)
- PR 合併指標
- (平均合併 8天) (30 天內合併 378 個 PR)
描述
Currently HeaderParser::configure (via the parserInternal helper method) splits a string into fixed and dynamic HeaderFormatter implementations, but delegates parsing of the dynamic HeaderFormatter arguments to the actual Formatter. In practice this means each Formatter has to do its own argument parsing when most of them will likely just take a single string.
I propose to modify the constructor for RequestInfoHeaderFormatter to take a formatter name (e.g., "START_TIME", "UPSTREAM_METADATA", "PROTOCOL", etc...) and a collection of 0 or more string arguments. This will allow us to push the parsing of arguments down into HeaderParser::configure/parseInternal. Initially we'll accept the existing "JSON array of strings" and unquoted string arguments used by UPSTREAM_METADATA and START_TIME. We'll add a quoted string (with appropriate backslash de-escaping) that can be used interchangeably with the unquoted string for single-argument formatters.
Doing this will make it possible to adopt an alternative to the clunky JSON array syntax for formatters that take 2 or more arguments, although I don't purpose to do that at this point.
Relevant Links: #4148.