An Overview of Go Web Frameworks
Introduction
Exploration of http servers in Go. The packages under considerations are,
- net/http
- https://github.com/go-chi/chi
- https://github.com/julienschmidt/httprouter
- https://github.com/gorilla/mux
- https://github.com/zenazn/goji/
- https://github.com/go-swagger/go-swagger
- https://github.com/manyminds/api2go
- https://github.com/labstack/echo
https://github.com/go-chi/chi
chi
is a lightweight, idiomatic and composable router for building Go 1.7+ HTTP services.- Designed to support larg REST API services.
- built on top of
context
a go package that handles signaling, cancelation and request-scoped values across a handler chain. - The features reported in the readme are,
- Lightweight - cloc’d in ~1000 LOC for the chi router
- Fast - yes, see benchmarks
- 100% compatible with net/http - use any http or middleware pkg in the ecosystem that is also compatible with net/http
- Designed for modular/composable APIs - middlewares, inline middlewares, route groups and subrouter mounting
- Context control - built on new context package, providing value chaining, cancelations and timeouts
- Robust - in production at Pressly, CloudFlare, Heroku, 99Designs, and many others (see discussion)
- Doc generation - docgen auto-generates routing documentation from your source to JSON or Markdown
- No external dependencies - plain ol’ Go 1.7+ stdlib + net/http
- Comes with a set of detailed examples
- MIT License
In numbers
- 3652 stars in github
- 46 contributors
- 472 commits
- 254 forks
- 17 releases
Remarks
- Growing dev community
- It looks like a suitable candidate for REST-API Serivices in Go
- the docs convinced me, they are clear
- well documented, looks simple to use
https://github.com/julienschmidt/httprouter
- HttpRouter is a lightweight high performance HTTP request router (also called multiplexer or just mux for short) for Go.
- Good scaling
- Good performance benchmarkings (claims to be amongst the bests)
- net/http compliance
- Well documented
- Lincense is not clear (GNU-like)
In numbers
- 7213 stars on github
- 32 contributors
- 206 commits
- 718 forks
- 2 releases
Remarks
- The license is not clear
- Has an interesinting backing community
https://github.com/gorilla/mux
- Package gorilla/mux implements a request router and dispatcher for matching incoming requests to their respective handler.
- Not a REST specific
- More of an http router
- net/http compliant
In numbers
- 6435 stars on github
- 66 contributors
- 238 commits
- 778 forks
- 8 releases
Remarks
- Not REST Specific, this makes gorilla/mux a non suitable candidate
- good backing community in its favor
- well documented
https://goji.io/
-
Goji is a HTTP request multiplexer, similar to net/http.ServeMux.
-
Goji itself has very few features: it is first and foremost a standard set of interfaces for writing web applications. Several subpackages are distributed with Goji to provide standard production-ready implementations of several of the interfaces, however users are also encouraged to implement the interfaces on their own, especially if their needs are unusual.
-
MIT License
In numbers
- 649 stars on github
- 4 contributors
- 51 commits
- 45 forks
- 3 releases
Remarks
- Not a suitable prospect
- Not very active, though some people recommended it
https://github.com/labstack/echo
- Optimized HTTP router which smartly prioritize routes
- Build robust and scalable RESTful APIs
- Group APIs
- Extensible middleware framework
- Define middleware at root, group or route level
- Data binding for JSON, XML and form payload
- Handy functions to send variety of HTTP responses
- Centralized HTTP error handling
- Template rendering with any template engine
- Define your format for the logger
- Highly customizable
- Automatic TLS via Let’s Encrypt
- HTTP/2 support
- MIT License
In numbers
- 10790 stars on github
- 103 contributors
- 1207 commits
- 950 forks
- 57 releases
Remarks
- Has very active development
- has a good backing community
- Benchmarks show good performance (or the say so)
- well documented, looks simple to use
https://github.com/manyminds/api2go
A JSON API Implementation for Go, to be used e.g. as server for Ember Data.
In numbers
- 519 stars on github
- 23 contributors
- 521 commits
- 66 forks
- 10 releases
Remarks
- Doesn’t look appealing, since JSON API is not our primary objective
- I’m not really convinced with the project whatsoever
https://github.com/go-swagger/go-swagger
-
Sponsored by VMWare
-
golang implementation of Swagger 2.0 (aka OpenAPI 2.0): it knows how to serialize and deserialize swagger specifications.
-
go-swagger brings to the go community a complete suite of fully-featured, high-performance, API components to work with a Swagger API: server, client and data model.
Generates a server from a swagger specification Generates a client from a swagger specification Supports most features offered by jsonschema and swagger, including polymorphism Generates a swagger specification from annotated go code Additional tools to work with a swagger spec Great customization features, with vendor extensions and customizable templates
- Apache 2.0 License
In numbers
- 2391 stars on github
- 144 contributors
- 2185 commits
- 440 forks
- 36 releases
Remarks
- I’m not sure if SWAGGER 2.0 is what we want, if so it looks like a good candidate
- Well documented and with a good dev community