refactor HeaderParser to make implementation of formatters easier/saner
#4.221 aberto em 21 de ago. de 2018
Métricas do repositório
- Stars
- (27.997 stars)
- Métricas de merge de PR
- (Mesclagem média 8d) (378 fundiu PRs em 30d)
Description
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.