nrfiber

package module
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 2, 2021 License: Apache-2.0 Imports: 5 Imported by: 2

README

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

Documentation

Index

Constants

This section is empty.

Variables

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

ConfigDefault is the default config

Functions

func New

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

New creates a new middleware handler

Types

type Config

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. Default: empty Application
	NewRelicApp *newrelic.Application
}

Config defines the config for middleware.

type ResponseWriter

type ResponseWriter struct {
	// contains filtered or unexported fields
}

ResponseWriter imitates http.ResponseWriter

func (*ResponseWriter) Header

func (rw *ResponseWriter) Header() http.Header

Header implementation

func (*ResponseWriter) Write

func (rw *ResponseWriter) Write(p []byte) (int, error)

Write implementation

func (*ResponseWriter) WriteHeader

func (rw *ResponseWriter) WriteHeader(statusCode int)

WriteHeader implementation

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL