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

Clarify usage of PostAgent #2358

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Clarify usage of PostAgent #2358

wants to merge 3 commits into from

Conversation

a10kiloham
Copy link
Contributor

No description provided.

Copy link
Contributor Author

@a10kiloham a10kiloham left a comment

Choose a reason for hiding this comment

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

fix format

@@ -25,7 +25,7 @@ class PostAgent < Agent

Change `content_type` to `xml` to send XML, where the name of the root element may be specified using `xml_root`, defaulting to `post`.

When `content_type` contains a [MIME](https://en.wikipedia.org/wiki/Media_type) type, and `payload` is a string, its interpolated value will be sent as a string in the HTTP request's body and the request's `Content-Type` HTTP header will be set to `content_type`. When `payload` is a string `no_merge` has to be set to `true`.
If `content_type` contains a [MIME](https://en.wikipedia.org/wiki/Media_type) type such as `text/plain`, the data are emitted raw. If `payload` is a string, its interpolated value will be sent as a string in the HTTP request's body and the request's `Content-Type` HTTP header will be set to `content_type`. When `payload` is a string `no_merge` has to be set to `true`. This can also be used to directly output json (as MIME type `application/json`) from incoming event as the payload, using either `{{ payload | json}}` or `{{payload | as_object }}` depending on formatting desired.
Copy link
Collaborator

Choose a reason for hiding this comment

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

What do you think about this?

If `content_type` contains a [MIME](https://en.wikipedia.org/wiki/Media_type) type such as `text/plain`, the interpolated value of `payload` will be sent as a string in the HTTP request's body and the request's `Content-Type` HTTP header will be set to `content_type`.

Maybe

This can also be used to convert the whole incoming event to JSON (as MIME type `application/json`) using either `{{ payload | json}}` or `{{payload | as_object }}` depending on the formatting desired.

?
It actually does not matter what is used as a payload, we always send the interpolated value as a string, even hashes and arrays will be send as the ruby string interpolation: https://hugrequestbin.herokuapp.com/15yxoax1?inspect

Copy link
Contributor Author

@a10kiloham a10kiloham left a comment

Choose a reason for hiding this comment

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

lgtm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants