5 ms·
I've found the standard library to be more than capable for most CRUD style apps. You can add in simple middleware chaining using a library such as Alice (https
by deepanchor 11y ago
I've found the standard library to be more than capable for most CRUD style apps. You can add in simple middleware chaining using a library such as Alice (https://github.com/justinas/alice https://github.com/justinas/alice) and for passing around request contexts between them, you can use something like xhandler (https://github.com/rs/xhandler https://github.com/rs/xhandler).
If you want more performant or flexible routing, httprouter (https://github.com/julienschmidt/httprouter https://github.com/julienschmidt/httprouter) has a nice feature set.
Maybe it's personal preference, but there's something more satisfying about the modular approach of building up an app using only components I need and understand, rather than starting with a magical feature-laden framework but quickly realizing you don't need half of what it does. I think Go aligns particularly well with this philosophy given its emphasis on composition.
- lobster_johnson 11y agoThat's the libraries I use, too. I really wish contexts were built into Go's HTTP library. Without contexts, you have to use global variables to accomplish things like per-request logging and access to configuration data. Not to mention that since goroutines cannot be forcibly terminated, it's the only way to control the lifetime of a handler (e.g. applying timeouts).
- pkates 11y agoYou may be looking for https://godoc.org/golang.org/x/net/context https://godoc.org/golang.org/x/net/context which is likely to make it into stdlib in the 1.7 timeframe from what I've seen in various channels. Doesn't quite solve the global logging problem though.
- lobster_johnson 11y agoYep, that's the context we (I and the grandparent comment) are using.