Skip to content

Allow passing closures to routes.#14

Open
eltair wants to merge 2 commits into
fengsp:masterfrom
eltair:closures
Open

Allow passing closures to routes.#14
eltair wants to merge 2 commits into
fengsp:masterfrom
eltair:closures

Conversation

@eltair
Copy link
Copy Markdown

@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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor

👍

@afaur
Copy link
Copy Markdown

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.

4 participants