4 ms·
Isn't it the same as *gin.context in go gin ? From what I see (not an experienced Go programmer), in gin you get the request through gin.context and in Chi you
by JodieBenitez 4y ago
Isn't it the same as *gin.context in go gin ? From what I see (not an experienced Go programmer), in gin you get the request through gin.context and in Chi you get the context through the request ?
- grose 4y agoThe context package didn't exist when Gin was created, so they invented their own solution. There was a proliferation of these context types until the standard library created a common solution. chi uses it, but Echo doesn't. The biggest advantage is that the stdlib context key type is interface{}, so you can use unexported types to create private key namespaces. It's also immutable and thread-safe. Gin and Echo use plain strings that are easy to clobber. This blog post discusses how the stdlib context works: https://go.dev/blog/context https://go.dev/blog/context (see userip bit about the unexported types). In many ways, Echo is a "better Gin".
- JodieBenitez 4y agoThanks for taking the time to explain. I see Gin can expose the stdlib context: router.GET("/", func(context *gin.Context) {context.Request.Context()}) > In many ways, Echo is a "better Gin". Interesting. I find it difficult to compare the plethora of web frameworks in Go. But coming from Python, I'm also familiar to this kind of situation...