-
Notifications
You must be signed in to change notification settings - Fork 118
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
Adding plugin support #227
Conversation
Looks like I'll be adding a third handle to the plugin, for the automatic redirect or response based on conditions. That way, an auth plugin, for example, can do something like redirect traffic if a particular router always requires an authenticated user. Philosophically, I'm not making it easy to write a plugin; the concentration is on ease of use of plugins by the website developer. The plugin library author, on the other hand, will be jumping through quite a few hoops. |
Hmmm...other routers referenced by "extend" end up globbing together into a single "allRoutes" block. I'm going to be changing that so that plugins and other things are decoratable on a per-router basis. I'll be explicit here in how it changes things. It should have no effect on performance. Edit: actually I'm keeping the "globbing together" behavior. Changing that would likely break a lot of existing websites. Instead I've added a |
unique to the context of the router. These blocks can use/modify the plugin variable. Plus, they can, using a template, invoke `break routesList` to do redirection without breaking the plugins.
Ready for review... mostly. Two quick items:
Also, I've got two plugins working. It is probably best to try it out with the cookieMsgs plugin since the other would require access to a mongodb server. I've also got three other private plugins working (simultaneously) on one of my web sites. Links to the public plugins: I've also written two doc files and have them linked from the README. |
If curious, the error I'm getting on
I wonder if I need a specific version of the compiler... |
Yep. Downgraded So, I have tested the test code; fixed it, and..as a bonus... fixed a newly discovered edge case bug. :) This will be the last commit I make so that you can examine unchanging code. |
In creating the https://github.com/JohnAD/jesterjson plugin, I discovered a fairly serious bug: since the "wildcard" parameters of a URL are not put into request.params until after the route block has started, those entry(s) are missing. I can totally see where that would cause a problem. And, moving where the While I'm at it, I'm going to:
So, instead of:
It will be:
I hope to have this done and documented in the next 24 hours. But I am, as always, willing to change direction if anyone has feedback. Thoughts? |
Wow. That was easier to update than I thought it would be. All tests pass; the docs have been updated. Ready for review once again! |
@dom96 I'm at FOSDEM. If interested in meeting up on this (or anything else), email me at [redacted-from-public]. |
Hey @JohnAD, sorry I missed your messages. It was nice meeting you at FOSDEM, it's a shame we didn't get a chance to speak for longer! Please feel free to email me to ping me about this PR, my email is at https://picheta.me. I currently don't have the time to review this PR as it's quite large, so it may take me a while to get through it. It looks like you've implemented some really cool functionality though! |
@JohnAD thx for the PR! I had a chance to kick some tires and it seems to be working well. I did have a few head scratches but I think that was due to me really not being very good at For example, I wanted to have no return value from a plugin, but seemed to be forced to use one. Another hiccup I ran into was not having the correct modules in scope at the top-level. A well-placed I'd say all-in-all this was a success. Perhaps I've spent too much time in Thank you both @JohnAD and @dom96. Edit 1: Typos. Typos everywhere. |
@skellock, Thanks for testing out the PR to such an extent! I could certainly could add a syntax variant that did not create a variable. So that: routes:
plugin newJsonPostsOnlyPlugin()
plugin sample <- newSamplePlugin("Steve") would both work. I've also toyed with the idea of making it look like an actual assignment statement. In which case it could look like: routes:
plugin discard newJsonPostsOnlyPlugin()
plugin var sample = newSamplePlugin("Steve") The problem with that direction is that it implies that the text after |
As discussed in more detail here: I will be creating a temporary fork available on nimble and the merger of plugins will occur at a later date. Meanwhile, I will go ahead and close this PR. |
Please do not accept this pull request. It is a work in progress [WIP] and I'm only placing this here for possible feedback as I build this.TODO:
result
response tuple.The first plugin I write will be for using cookies for cross-page messaging. It would be used something like: