Skip to content
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

Allow passing closures to routes. #14

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

eltair
Copy link

@eltair eltair commented Mar 24, 2016

While trying pencil, I almost immediately wanted to pass closures to the route functions instead of function pointers. In particular, this allows for capturing config information loaded at startup (eg api keys).

There are more places that take function pointers which should probably also be changed before this is merged, but I wanted to get your feedback first.

@fengsp
Copy link
Owner

fengsp commented Mar 25, 2016

@eltair I'd appreciate it if you can add some working example code in the comment. Let's see how the api looks like.

@eltair
Copy link
Author

eltair commented Mar 25, 2016

Your existing hello example app should continue to work without modification, but I added a few more routes that show the use of closures.

@scorphus
Copy link
Contributor

👍

@afaur
Copy link

afaur commented Jul 2, 2016

I wanted to get this work into my fork of master to test with.

I did a rebase and got it to merge into my fork of master, and then located an issue that I overlooked when deciding what to keep or not. I also found an issue with the example that I corrected.

If you want to see what worked for me to get this into a recent master it can be found here: https://github.com/afaur/pencil/tree/closures

I also have a simple example pencil web app that was forked and adjusted from archaelus. I modified it to set up a closure route for testing.

I also added a few instructions to the readme to explain how to set it up to test the closures branch of pencil. It can be found here: https://github.com/afaur/rello/tree/closures-branch-test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants