This Go package was archived. What do we do now?

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
on December the 9th 2022 something happened that would change the way apis were written and go for thousands of Developers on that day the gorilla mux package along with the entire gorilla toolkit was archived no more commits or updates would be made if you're unaware gorilla mux is one of the most popular go packages for handling API routing the reason it's so popular is because it hooks into the HTTP Handler interface of the standard Library which is considered a very good thing by go developers on top of that it provides a lot of necessary functionality for routing HTTP requests that are difficult to achieve with a standard Library alone if you've ever tried to use HTTP server marks then you know what I mean some of the features that Gorilla Max provides are path-based routing and parameters with regex support for both routing based on HTTP properties such as HTTP methods or HTTP headers and middleware either through custom functions or through the middleware package provided by the toolkit as for the user submux well looking at the stats on GitHub it's used by over a hundred thousand public repositories and likely many more private ones so what happened well according to the maintainers they no longer had the capacity to continue maintaining the code base and despite asking for volunteers to take over the project no one did therefore the project was archived to read-only mode with no further updates being made well what next was there's no urgency to do so now it's probably a good idea to think about migrating away from gorilla mucks in the near future I'm going to look at three other options for HTTP routing and go and what I believe this means for the language in the long term gin is a web framework that is written in go it claims up to 40 times performance when compared to the standard library due to its custom HTTP router Jin has support for many features such as middleware path parameters and open Telemetry out of the box but unfortunately does not support Rogue x-based routing when compared to Guerrilla mux routes are created in Gin by using the method function and setting the path followed by the Handler function this differs from gorilla mocks as the method is used as part of the routing by default but follows with more traditional Frameworks such as Express gin uses its own custom Handler type which makes use of a gin.context instead of the HTTP Handler interface of the standard Library personally I'm not the biggest fan of this but it does enable a number of helpful methods such as simplified Json encoding validation and other functions that one may need for HTTP handling if you are migrating from a gorilla mugs project you can use gin with your existing HTTP handlers to do so you can use the wrap F or wrap H methods to wrap an HTTP function or Handler respectively this won't work for any requests that make use of the max files function but it should soften the blow over full migration overall gin is a worthy Contender and whilst it doesn't conform to the HTTP Handler interface it makes up for this by providing a lot of functionality and performance Echo is another web framework that is very comparable to Gin just like gin Echo provides support for path parameters middleware and open Telemetry whilst also lacking support for rogue X Echo uses a similar interface as gin for defining routes in which the method function is used followed by the path and the Handler function in Echo the Handler function provides an echo dot context which similar to Jin can be used to read data from the request and send a response back to the client the main difference when compared to Gin however is that an error also has to be returned in this Handler function by default when an error is returned the server will return HTTP status 500 to the client if you're looking to migrate from mux to Echo the framework also provides a wrapper function to wrap the standard HTTP Handler in an echo Handler this too suffers the same problem when it comes to migrating the mux.files function overall Echo is a nice alternative to Gin however it has a smaller community and does not boast as much performance ultimately when choosing between the two it'll come down to personal preference if you're like me and really want to keep with the HTTP Handler interface provided by the standard library then Qi is a compelling option with Qi you create a router type that can then be used with your HTTP handlers which makes migration very easy to do when it comes to path parameters one can replace any instances of the max files function call with the QI URL pram instead which will perform the same operation as well as standard routing Qi also provides some useful middleware functions this is the recommended bass middleware stack which provides access to a request ID the real IP of the client using the x44 header a logger and a recoverer in case of panics one thing to consider however is that she does not support open Telemetry out of the box fortunately we can use another package Oto Chi to achieve this overall Chi is worthy of consideration in my opinion despite having a smaller community and a less active code base ultimately I think it's a huge shame to lose not only the gorilla mux package but also the entire gorilla toolkit which held a number of valuable packages for maintaining services such as websockets middleware Json RPC and many others whilst I think this is going to only amount to a moderate headache for go developers it does raise greater concerns about dependencies especially within the go ecosystem gorilla failing to find maintainers is something I wouldn't have expected especially given the amount of people and companies using go and the package itself ultimately I would love to see some better routing capabilities added to the standard library of go HTTP serve mux does exist but it's woefully lacking compared to what gorilla marks offered when it comes to The Replacements I will personally consider using Qi in the future I'm interested to hear about the other Replacements that I haven't talked about and what any of you watching will be using personally as always thank you for watching and I'll see you on the next one
Info
Channel: Dreams of Code
Views: 60,429
Rating: undefined out of 5
Keywords: golang, go, gorilla, web service, web router, router, http router, gorilla/mux, mux, go mux, toolkit, goirlla, golang router, http server, go api, api, golng, go lang, web routes, path parameters, regex, regex routing, http methods
Id: j584uJhWWhE
Channel Id: undefined
Length: 5min 52sec (352 seconds)
Published: Sun Apr 09 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.