Skip to content

Latest commit

 

History

History
75 lines (57 loc) · 1.48 KB

README.md

File metadata and controls

75 lines (57 loc) · 1.48 KB

NewRelic Integration Middleware

Go Reference

NewRelic Integration middleware for Fiber.

Table of Contents

Signatures

func New(config ...Config) fiber.Handler

Examples

First import the middleware,

import (
  "github.com/gofiber/fiber/v2"
  "github.com/nobuyo/nrfiber"
)

Then create a Fiber app with app := fiber.New().

Default Config

nrapp, err := newrelic.NewApplication(
	newrelic.ConfigAppName("Application Name"),
	newrelic.ConfigLicense(os.Getenv("NEW_RELIC_LICENSE_KEY")),
	newrelic.ConfigDebugLogger(os.Stdout),
)

app.Use(nrfiber.New(nrfiber.Config{
	NewRelicApp: nrapp
}))

Config

// Config defines the config for middleware.
type Config struct {
	// Next defines a function to skip this middleware when returned true.
	//
	// Optional. Default: nil
	Next func(c *fiber.Ctx) bool

	// NewRelicApp is newrelic.Application
	//
	// Required.
	NewRelicApp *newrelic.Application
}

Default Config

var ConfigDefault = Config{
	Next:        nil,
	NewRelicApp: &newrelic.Application{},
}