Migrating our shopping list API to Echo
Echo is easy to set up and use, so it won’t be hard to incorporate it into our existing shopping list API. We only need to initialize our echo instance and register our handlers. Of course, we will also need to update our handlers so that they use echo.Context instead of the standard http.ResponseWriter and *http.Request parameters, but that is not a big deal. It’s time to jump right into it.
Setting up Echo
The first thing we need to do is prepare our Echo instance and update our router so that it uses Echo’s routing system in our main.go file:
func main() {
e := echo.New()
api := e.Group("/api")
api.Use(authRequired)
...
e.POST("/api/login", handleLogin)
api.GET("/lists", handleGetLists)
api.POST("/lists", adminRequired(handleCreateList))
api.GET("/lists/:id", handleGetList)
api.PUT("/lists/:id", adminRequired(handleUpdateList))
...