lpereira / lwan

Experimental, scalable, high performance HTTP server
https://lwan.ws
GNU General Public License v2.0
5.94k stars 548 forks source link

Is there a way to pass parameters to handlers such as db conn objects ? #190

Closed GuacheSuede closed 7 years ago

GuacheSuede commented 7 years ago

eg { .prefix = "/hello", .handler = helloWorld(conn)} Or perhaps though lambdas

lpereira commented 7 years ago

Yes, there's space for a void*. Follow the tutorial, it's explained there.

On Mon, Feb 27, 2017, 16:47 Justin Yeap notifications@github.com wrote:

eg { .prefix = "/hello", .handler = helloWorld(conn)} Or perhaps though lambdas

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/lpereira/lwan/issues/190, or mute the thread https://github.com/notifications/unsubscribe-auth/AAA6mdCRQc-bw_jiz_lJ6eBpN_61IYjyks5rg26VgaJpZM4MN0xW .

GuacheSuede commented 7 years ago

are you talking abt this void *data __attribute__((unused)) ?

lpereira commented 7 years ago

The data member in the struct lwan_url_map will be passed to the handler as the data parameter, yes. In the case of the part you've pasted, this handler has no use for data, so it was marked as unused to keep the compiler from complaining.

GuacheSuede commented 7 years ago

Alright sure, Thank you.