envoyproxy/envoy

refactor HeaderParser to make implementation of formatters easier/saner

Open

#4 221 ouverte le 21 août 2018

Voir sur GitHub
 (0 commentaires) (0 réactions) (0 assignés)C++ (5 373 forks)batch import
help wanted

Métriques du dépôt

Stars
 (27 997 stars)
Métriques de merge PR
 (Merge moyen 8j) (378 PRs mergées en 30 j)

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.

Guide contributeur