-
Notifications
You must be signed in to change notification settings - Fork 12
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
adjustments #10
adjustments #10
Conversation
@@ -80,14 +81,14 @@ var loadPolicies = function(server, policyDirectory, next) { | |||
data.names.push(match[1]); | |||
|
|||
// Add this policy function to the data object | |||
var policy = require(path.join(policyDirectory, filename)); | |||
var policy = require(path.join(options.policyDirectory, filename)); |
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.
'require' is not defined.
Thanks @PavelPolyakov. On item #2 You took an interesting approach to being able to switch out the extension points. It's spurred some thoughts for me. One thing I would like to preserve is the option to bind policies to any and all extension points, rather than limited to just two, a "pre" and a "post". I think we need to allow policies to bind to any of the events, so I'll probably pull this PR in but alter it so that policies still need to specify which events to bind to, but extend MrHorse to work with all current Hapi events in the request life cycle. So, for instance, each policy can indicate that it should bind to onRequest, onPreAuth, onPostAuth, onPreRender, onPostRender, etc. That would allow for maximum flexibility. |
@mark-bradshaw But, to make it more general, I think we can do it in the way when it should be stated in the policy - where to apply it. And default application point should be stated for the whole plugin. What do you think? |
I had some scenarios int he past, but I can't come up with an example right So to recap, I'm not so concerned with the option to run a single policy on I still think that onPreHandler makes the most sense as a default, but I On Mon, May 18, 2015 at 3:25 PM Pavel notifications@github.com wrote:
|
Also, thanks for the PR. I'd like to see those modifications we've talked about before merging, but I've added you as a collaborator to the repo. |
@mark-bradshaw I would update it in the way so it's possible to set the application point right in the policy, the default one would be |
So each policy would just have one event it would bind to, and that is set On Mon, May 18, 2015 at 3:52 PM Pavel notifications@github.com wrote:
|
@mark-bradshaw |
OK. Works for me. Please make the necessary modifications and then merge On Mon, May 18, 2015 at 4:00 PM Pavel notifications@github.com wrote:
|
_applyPoints.forEach(function (applyPoint) { | ||
handlers[applyPoint] = function (request, reply) { | ||
runPolicies(data[applyPoint], request, reply); | ||
} |
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.
Missing semicolon.
@mark-bradshaw The concept is like we've discussed.
The list of the possible application points is hardcoded. Looking forward for the feedback. |
Thanks a ton. I'll review that and get back to you. On Tue, May 19, 2015 at 7:51 AM Pavel notifications@github.com wrote:
|
Looks good to me. Very well done. We have slightly different code styles, but it's close enough that we probably don't need a style guide for contributions at this moment. In general I try to follow the hapi style guide, but I don't follow it exactly. I should probably making a CONTRIBUTING.md file and mention that. So, here's some follow on items I can think of:
|
data.setPreHandler = true; | ||
} | ||
// Check if the apply point is correct | ||
if(policy.applyPoint && _applyPoints.indexOf(policy.applyPoint) === -1) { |
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.
Line is too long.
'_applyPoints' is not defined.
if (policy.pre === undefined || policy.pre) { | ||
server.log(['info'], 'Adding a new PRE policy called ' + match[1]); | ||
data.pre[match[1]] = policy; | ||
var policy = require(path.join(options.policyDirectory, filename)); |
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.
'require' is not defined.
@PavelPolyakov It looks like you're all done. Looks fine to me. Feel free to merge unless you have more you want to do. |
support of the request.reply in the next() support of the different application points for the policies
@mark-bradshaw I've merged the pull request and created the release. Is that something you should do? Or I can do it myself somehow. Just in case, me on the npm: https://www.npmjs.com/~pavel.polyakov |
I'll take care of it. I'm adjusting the README a bit and updating tests. On Wed, May 20, 2015 at 2:21 AM Pavel notifications@github.com wrote:
|
Thanks, I'm waiting to include it in the project we're working on. |
OK. I'm waiting for Travis to verify all the tests, and then I'll publish. On Wed, May 20, 2015 at 10:31 AM Pavel notifications@github.com wrote:
|
It's done. I've pushed v1.0.0 to npm. Just as a note, I altered the On Wed, May 20, 2015 at 10:40 AM Mark Bradshaw mark.bradshaw@gmail.com
|
Should we wait for some time? Because here: I see 0.0.3 still. |
Yes. It'll take a bit of time to show up. On Wed, May 20, 2015 at 12:06 PM Pavel notifications@github.com wrote:
|
@mark-bradshaw |
It's odd. I definitely published yesterday. I tried again this morning to Just for kicks I tried again with a minor version bump, and published again I've contacted npm support. Hopefully they can clue me in. If you have Mark On Thu, May 21, 2015 at 2:25 AM Pavel notifications@github.com wrote:
|
My second try just went through. So apparently it's safer just to use the On Thu, May 21, 2015 at 7:24 AM Mark Bradshaw mark.bradshaw@gmail.com
|
onPreHandler
andonPostHandler