Middlewares for Echo Framework
Requires Go 1.9 or later.
go get github.com/dafiti/echo-middleware
- New Relic
- LoggerWithOutput (Retrieves Logger middleware with Output)
- Logrus (Http request logs)
package main
import (
"bytes"
"net/http"
mw "github.com/dafiti/echo-middleware"
"github.com/labstack/echo"
)
func main() {
e := echo.New()
e.Use(mw.NewRelic("app name", "license key"))
// Default Logger middleware
//buf := new(bytes.Buffer)
//e.Use(mw.LoggerWithOutput(buf))
// Logrus HTTP request logs
e.Use(mw.Logrus())
e.GET("/", func(c echo.Context) error {
txn := c.Get("newrelic-txn").(newrelic.Transaction)
defer newrelic.StartSegment(txn, "mySegmentName").End()
return c.String(http.StatusOK, "Hello, World!")
})
e.Logger.Fatal(e.Start(":1323"))
}
Read the full documentation at https://godoc.org/github.com/dafiti/echo-middleware.
This project is released under the MIT licence. See LICENCE for more details.