Reputation: 45
I installed echo via
go get -u github.com/labstack/echo/v4
Its package in go.mod
like
module app
go 1.15
require (
github.com/labstack/echo v3.3.10+incompatible
github.com/labstack/echo/v4 v4.2.0
)
In server.go
, use a middleware as
package app
import (
"github.com/labstack/echo/v4"
"github.com/labstack/echo/middleware"
)
func main() {
e := echo.New()
e.Use(middleware.Logger())
}
It alert too few arguments in call to middleware.Logger
.
Other middleware also can't been used.
Upvotes: 1
Views: 4904
Reputation: 86
try this
package main
import (
"net/http"
"github.com/labstack/echo/v4"
"github.com/labstack/echo/v4/middleware"
)
func main() {
e := echo.New()
e.Use(middleware.Logger())
e.GET("/", func(c echo.Context) error {
return c.String(http.StatusOK, "Hello World")
})
e.Logger.Fatal(e.Start(":9000"))
}
and in go.mod only just it
module app
go 1.15
require github.com/labstack/echo/v4 v4.2.0
Upvotes: 2