Skip to content

nobuyo/nrfiber

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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{},
}