jsonrpc
jsonrpc copied to clipboard
Support middlewares
WHAT
Support middlewares
WHY
see #45
Nice contribution!
I suggest you add global middleware support. For example for logging or metrics.
To have something like this:
mr.UseMiddleware(LoggingMiddleware(logger))
mr.UseMiddleware(MetricsMiddleware(prometheus_client))
Also, some examples/docs would be nice.
@lcd1232 Sorry for the code review.
Thanks for suggesting the middleware implementation. It would be nice if you could do a PR for the middleware implementation only since it is mixed with context operations as well as the middleware implementation.
As @kochetkov-av mentioned, I agree with the way he suggested. like a chi middleware, https://github.com/go-chi/chi
@osamingo I fixed all issues
My suggestion is to add "after" middleware test if order testing, like this:
res, err := next(c, params)
buf.WriteString(s)
return res, err