github.com/CGems/echo-middleware/v4

Middlewares for Echo Framework


License
MIT
Install
go get github.com/CGems/echo-middleware/v4

Documentation

Echo Middlewares

Build Status Coverage Status GoDoc Go Report Card License

Middlewares for Echo Framework

Installation

Requires Go 1.9 or later.

go get github.com/dafiti/echo-middleware

Middlewares

  • New Relic
  • LoggerWithOutput (Retrieves Logger middleware with Output)
  • Logrus (Http request logs)

Usage Examples

package main

import (
    "bytes"
    "net/http"
	mw "github.com/dafiti/echo-middleware"
    "github.com/labstack/echo/v4"
)

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"))
}

Documentation

Read the full documentation at https://godoc.org/github.com/dafiti/echo-middleware.

License

This project is released under the MIT licence. See LICENCE for more details.