[question] How to use the option when initialize the middleware
gaocegege opened this issue · comments
Is this a BUG REPORT or FEATURE REQUEST?:
/kind question
I implement a customized middleware to add the DB interface to the context, and the middleware supports different DB backends (e.g. SQLite3, MySQL and so on), thus I use the option to let users define the backend.
But, I found that we cannot use the option before cmd.ExecuteWithConfig
, since the values will all be empty before the command is actually run. While the middleware should be configured before the cmd is run, I am not sure if we could use the option in middleware in the current design. Do you have any suggestion?
I'd appreciate it if you could answer.
Middleware is a concept of router. You need to implement a plugin witch install a db middleware to router.
Here is the document which describes how to implement plugins: https://caicloud.github.io/nirvana/zh-hans/concepts/plugin.html
Also you can find an example at: https://github.com/caicloud/nirvana/blob/master/plugins/reqlog/reqlog.go
Thanks, gotcha. I implemented a middleware directly. It seems that I misunderstand the concept of middleware. I will take a look.