Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support middlewares #49

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open

Conversation

lcd1232
Copy link

@lcd1232 lcd1232 commented Apr 8, 2021

WHAT

Support middlewares

WHY

see #45

@kochetkov-av
Copy link

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.

@osamingo
Copy link
Owner

@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

@lcd1232
Copy link
Author

lcd1232 commented Oct 15, 2021

@osamingo I fixed all issues

@kochetkov-av
Copy link

kochetkov-av commented Oct 19, 2021

My suggestion is to add "after" middleware test if order testing, like this:

res, err := next(c, params)
buf.WriteString(s)
return res, err

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants