HTTPTarget improvements by tzununbekov · Pull Request #1391 · triggermesh/triggermesh · GitHub
Skip to content
This repository was archived by the owner on Nov 5, 2024. It is now read-only.

HTTPTarget improvements#1391

Merged
tzununbekov merged 2 commits into
mainfrom
httptarget-update
Apr 17, 2023
Merged

HTTPTarget improvements#1391
tzununbekov merged 2 commits into
mainfrom
httptarget-update

Conversation

@tzununbekov

@tzununbekov tzununbekov commented Apr 13, 2023

Copy link
Copy Markdown
Member

HTTPTarget improvements:

  1. Expected request body type switched from string to json.RawMessage to handle JSON data. The use-case to reproduce the issue is simple: Webhook source -> Transformation -> HTTP Target. Transformation in this context can either shift the whole Webhook payload to the body key or compose it from the multiple values of the source event. In both cases, the resulting body will be a JSON object, which is expected transformation behavior. Before this update, the target adapter complained about it: json: cannot unmarshal object into Go struct field RequestData.body of type string,
  2. CR's spec.response.* parameters are not required and without them the adapter fails to send back the responses (CE context validation). Default values for CE type and source attributes are added,
  3. HTTPTarget resource implements EventSource and EventReceiver interfaces to comply with the rest of the components. Resource's status exposes expected and produced CE attributes.

Upd:
4. Since the target's expected event has a rather strict format requirement, JSON schema was added to explicitly announce the request contract. The target adapter requires an incoming event to be of io.triggermesh.http.request type, otherwise event processing will fail.

@tzununbekov tzununbekov requested a review from a team April 13, 2023 09:52
@tzununbekov tzununbekov self-assigned this Apr 13, 2023
@tzununbekov

tzununbekov commented Apr 13, 2023

Copy link
Copy Markdown
Member Author

@tzununbekov tzununbekov marked this pull request as draft April 13, 2023 09:58
@odacremolbap

Copy link
Copy Markdown
Member

HTTPTarget is able to interact with non JSON systems.
Will it be able to do so after this proposed change?

@tzununbekov

Copy link
Copy Markdown
Member Author

@tzununbekov tzununbekov marked this pull request as ready for review April 13, 2023 10:57
@tzununbekov tzununbekov merged commit fb5907f into main Apr 17, 2023
@tzununbekov tzununbekov deleted the httptarget-update branch April 17, 2023 08:53
tzununbekov added a commit that referenced this pull request Apr 18, 2023
* HTTPTarget improvements

* HTTPTarget Accepted event schema and type added
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants