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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to convert existing http.Handler middleware to bunrouter one #90

Open
vkuznet opened this issue Apr 30, 2023 · 0 comments
Open

How to convert existing http.Handler middleware to bunrouter one #90

vkuznet opened this issue Apr 30, 2023 · 0 comments

Comments

@vkuznet
Copy link

vkuznet commented Apr 30, 2023

馃挕 The feature or bug you are proposing

Feature

馃搫 The description of the bug or the logic behind your proposal

The reason for this request is that there are plenty of existing middleware code base which provide standard http.Handler and it would be useful to re-use it within bunrouter.

For example, I'm interested to use existing legacy codebase based on gorilla/mux which and its middleware and easily convert it to bunrouter middleware. I managed to figure out mux router part, but I'm struggle to understand how easily re-use existing gorilla/mux middleware functions in bunrouter. Could you please provide a working example which will not require much of the rewrite for existing middleware codebase.

馃殌 The expected result

It would be extremely useful to get documentation how to convert gorilla/mux middleware to bunrouter one, e.g. how to use this code in bunrouter:

func loggingMiddleware(next http.Handler) http.Handler {
    return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
        // Do stuff here
        log.Println(r.RequestURI)
        // Call the next handler, which can be another middleware in the chain, or the final handler.
        next.ServeHTTP(w, r)
    })
}
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

No branches or pull requests

1 participant