gin-gonic / gin

Gin is a HTTP web framework written in Go (Golang). It features a Martini-like API with much better performance -- up to 40 times faster. If you need smashing performance, get yourself some Gin.
https://gin-gonic.com/
MIT License
79.22k stars 8.03k forks source link

Combine gorilla mux + gin gonic #3185

Open jmwielandt opened 2 years ago

jmwielandt commented 2 years ago

Description

We have a web server done with gorilla mux and we want to migrate it to gin gonic, but we won't going to do it all at once: we wanna do it gradually.

Is there a way to define a gin gonic router and include it inside my gorilla server? Or any other way to acomplish that migration?

Thanks!

fifsky commented 2 years ago

You may need an API gateway (Ingress, Traefik or nginx) to forward traffic on a specified path to gin Server

rn0l485 commented 2 years ago

Hi @jmwielandt

net/http gin gorilla/mux All of above are implements the http.HandlerFunc, you might be easily rebuild your function.

adonese commented 2 years ago

You can use a small adapter to serve net/http handler methods from gin, here's an example:

func ginAdapter() gin.HandlerFunc {
    return func(c *gin.Context) {
        yourHandler(c.Writer, c.Request)
    }
}