Is there a way to

Kyle Ingraham kyle at kyleingraham.com
Mon Sep 12 16:49:51 UTC 2022


On Sunday, 11 September 2022 at 00:56:39 UTC, Adam D Ruppe wrote:
> On Sunday, 11 September 2022 at 00:32:18 UTC, Kyle Ingraham 
> wrote:
>> I can't use default parameters because I want to be able to 
>> call the delegate with arguments extracted from a URL path at 
>> runtime
>
> Some kind of wrapper might not only be your best option, it 
> might be your only option.
>
> Your delegate would be like string callWith(string[][string] 
> webArgs) and you can generate a wrapper to convert arguments 
> and call the original function.
>
>> I'm mucking about with a custom router for vibe-d and trying 
>> to setup the ability for handlers to have different parameter 
>> signatures.
>
> I'd be surprised if vibe doesn't already have this built in, my 
> web frameworks have since before vibe was born. (my 
> implementation btw does the wrapper thing like described above)

Thanks for the wrapper suggestion Adam. I tried that out and got 
the functionality that I wanted. I wrap the handler in a delegate 
that has the signature I need.

vibe-d does have a way to achieve something similar but I'm 
working on a router that does a bit more path validation before 
calling a handler.


More information about the Digitalmars-d-learn mailing list