-
-
Notifications
You must be signed in to change notification settings - Fork 831
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
Proposal: introduce context provider command support #356
Comments
I like the idea that users can solve complex requirements without having to extend webhook in some weird way or at least not have to wait on us to extend webhook to solve their problem. I do have one suggestion. You're proposing a kind of pre-processor feature. Perhaps call it |
Not all character codes are allowed as a character in a string according to json specification. I think passing byte array (I'm talking about |
@AndrewSav correct, we should default to base64 encoded string. |
@moorereason Implemented the suggestions, does it look better now? :-) |
Changes look good, but I've got more feedback. 😃
|
Merged latest development to the feature branch. I'm hoping to write some examples during this week. Any help on tests and docs would be appreciated :-) I'm thinking this could be a good way forward to support esoteric scenarios and custom stuff by maintaining a standard library of functions and helpers for payload handling and processing in the pre-hook commands... |
Is a successful prehook required for successful hook execution? I would assume so in most scenarios. Why define a prehook if you don't care if it was successful? If we can assume they're required to be successful, several error-handling steps in One thing that often bugs me is how complex Overall, it looks good. I look forward to seeing your examples. If I have time, I'll try to help out with tests & docs. 👍 |
That is a good question! Come to think about it, it makes much more sense to make it required. You're also absolutely right about the |
Also, I'm thinking about including "response-headers", "response-http-status-code" and "response-message" in trigger rules, so when a rule node fails, it would override the default response message. This would allow implementing stuff like rate-limiting with pre-hook commands where the pre-hook command checks for currently running processes, and then injects a field in the context, which the hook would have in a trigger rule. |
Updated existing hook tests with the new context source. |
@moorereason Rebased the branch with latest changes from development. Still missing:
|
I agree. I would prefer that the only "context" usage we keep is the name of the |
Yep, exactly what I had in mind |
Merged latest development changes, and imeplemented early abort if prehook command fails for any reason. Also renamed Context to PreHook where applicable. Need docs & examples. |
Added some docs and an example to get the request IP :-) |
Sometimes it might be necessary to extend webhook with custom logic before the hook gets invoked.
In order to support that in modular case I propose implementing a "context provider command" support in webhook.
The context provider command would be executed whenever the hook gets matched. It would receive via STDIN a JSON representation of an object with following structure:
The context provider command is expected to output a valid JSON representation of an object which would be then stored in a special source named "context".
The special source would be usable in all places where one is able to use "payload" source.
This would allow users to implement custom payload parsers to extract required fields, or inject custom values that can be computed in runtime (i.e. custom signature verification, etc...) and pass them along to webhook's trigger rules etc...
The working implementation is available at the
feature/context-provider-command
branch. What's missing is documentation and tests.Any suggestions or comments?
@moorereason
The text was updated successfully, but these errors were encountered: