Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Fix REQ command operator usage example #13197

Merged
merged 3 commits into from
Sep 23, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions api/envoy/config/core/v3/substitution_format_string.proto
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,17 @@ message SubstitutionFormatString {
// Specify a format with command operators to form a text string.
// Its details is described in :ref:`format string<config_access_log_format_strings>`.
//
// .. code-block::
// For example, setting ``text_format`` like below,
//
// text_format: %LOCAL_REPLY_BODY%:%RESPONSE_CODE%:path=$REQ(:path)%
// .. code-block:: yaml
//
// The following plain text will be created:
// text_format: "%LOCAL_REPLY_BODY%:%RESPONSE_CODE%:path=%REQ(:path)%\n"
//
// .. code-block::
// generates plain text similar to:
//
// upstream connect error:204:path=/foo
// .. code-block:: text
//
// upstream connect error:503:path=/foo
//
string text_format = 1 [(validate.rules).string = {min_bytes: 1}];

Expand All @@ -41,11 +43,11 @@ message SubstitutionFormatString {
// Nested JSON objects may be produced by some command operators (e.g. FILTER_STATE or DYNAMIC_METADATA).
// See the documentation for a specific command operator for details.
//
// .. code-block::
// .. code-block:: yaml
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe consider using #11394 if it works here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, should the config validation be done automatically?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From looking at the PR, you would need to switch to validated-code-block.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Updated. But yeah, for $REQ()% vs %REQ()% I wish we can catch that too.

//
// json_format:
// status: %RESPONSE_CODE%
// message: %LOCAL_REPLY_BODY%
// status: "%RESPONSE_CODE%"
// message: "%LOCAL_REPLY_BODY%"
//
// The following JSON object would be created:
//
Expand All @@ -70,7 +72,7 @@ message SubstitutionFormatString {
// If this field is not set then ``text/plain`` is used for *text_format* and
// ``application/json`` is used for *json_format*.
//
// .. code-block::
// .. code-block:: yaml
//
// content_type: "text/html; charset=UTF-8"
//
Expand Down
20 changes: 11 additions & 9 deletions api/envoy/config/core/v4alpha/substitution_format_string.proto

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -571,27 +571,27 @@ message LocalReplyConfig {
// The configuration to form response body from the :ref:`command operators <config_access_log_command_operators>`
// and to specify response content type as one of: plain/text or application/json.
//
// Example one: plain/text body_format.
// Example one: "plain/text" ``body_format``.
//
// .. code-block::
// .. code-block:: yaml
//
// text_format: %LOCAL_REPLY_BODY%:%RESPONSE_CODE%:path=$REQ(:path)%
// text_format: "%LOCAL_REPLY_BODY%:%RESPONSE_CODE%:path=%REQ(:path)%\n"
//
// The following response body in `plain/text` format will be generated for a request with
// The following response body in "plain/text" format will be generated for a request with
// local reply body of "upstream connection error", response_code=503 and path=/foo.
//
// .. code-block::
// .. code-block:: text
//
// upstream connect error:503:path=/foo
//
// Example two: application/json body_format.
// Example two: "application/json" ``body_format``.
//
// .. code-block::
// .. code-block:: yaml
//
// json_format:
// status: %RESPONSE_CODE%
// message: %LOCAL_REPLY_BODY%
// path: $REQ(:path)%
// status: "%RESPONSE_CODE%"
// message: "%LOCAL_REPLY_BODY%"
// path: "$REQ(:path)%"
//
// The following response body in "application/json" format would be generated for a request with
// local reply body of "upstream connection error", response_code=503 and path=/foo.
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.