Passing a trait as a parameter to `Dict`?
This is related to a proposal for adding Middleware functionality to Lightbug HTTP: https://github.com/saviorand/lightbug_http/pull/33#issuecomment-2105547981
We're trying to do something like the following:
Where
routes: Dict[String, HTTPHandler]
takes in an HTTPHandler
trait which can be implemented by different handlers, including ones created by the user.
Currently, since Dict
expects a value that implements CollectionElement
, so we're getting the following error:
This persists even if HTTPHandler
extends CollectionElement
like so:
trait HTTPHandler(CollectionElement)
.
Any ideas on how we can get this to work?GitHub
Propose Middleware Solution by drujensen · Pull Request #33 · savio...
This is a proposal and code sample for adding middleware to the light bug project.
Proposal
The chain of responsibility design pattern is used to chain together pieces of middleware that will each ...
2 Replies
I think you can do the following:
This is great, the error is gone! Thanks!