-
Notifications
You must be signed in to change notification settings - Fork 29
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
Form encoded data #309
base: master
Are you sure you want to change the base?
Form encoded data #309
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,6 +41,8 @@ function buildPostOptions(action, event) { | |
} | ||
else if (action.template) { | ||
options.text = myutils.expandVar(action.template, event); | ||
}else if (action.parameters.form){ | ||
options.form = myutils.expandObject(action.parameters.form,event); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The line seems to be under-indented. Same in L68. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Style: whitespace between There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in the next commit |
||
} | ||
|
||
return options; | ||
|
@@ -62,7 +64,9 @@ function doIt(action, event, callback) { | |
else if (options.text) { | ||
requestOptions.body = options.text; | ||
} | ||
|
||
else if (options.form){ | ||
requestOptions.form = options.form; | ||
} | ||
metrics.IncMetrics(event.service, event.subservice, metrics.actionHttpPost); | ||
|
||
myutils.requestHelper(options.method.toLowerCase(), requestOptions, function(err, data) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking to the examples, it seems that "form" and "json" are mutually exclusive. Is my interpretation correct? What would happen if the action includes both "form" and "json" (I don't see anything in the code modifications checking that posibility)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it would make sense that they are mutually exclusive. Either you send the data as application/json or as application/x-www-form-urlencoded.
Should we restrict that in order to be accepted?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think so. Any other opinion? @cblanco what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My first approach would be to throw an exception if both fields are filled, but I think that it wouldn't follow the guidelines of this coding.
What do you think about this approach?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @fgalan @cblanco . I'm looking forward for your comments on this :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lest's consider the end-to-end perspective in the CEP API. I mean, what should happen in the case the user tries to use both "json" and "form" when creating or updating a rule is that he/she gets a 400 Bad Request response with an error telling about she/he cannot do that.
In addition: