Categorygithub.com/mxload/mxload_go
modulepackage
0.1.0
Repository: https://github.com/mxload/mxload_go.git
Documentation: pkg.go.dev

# README

mxload_go

Golang middleware for Mx.Load

Installation

go get github.com/mxload/mxload_go

Usage

go-chi

import (
    ...

    mxload "github.com/mxload/mxload_go"
)

func main() {
    r := chi.NewRouter()

    // Add mxload middleware
	r.Use(mxload.MiddlewareFunc(
        // mxload collector configuration
		&mxload.MxloadConfig{
			Enabled:      true, // Make collector enable/disable
			CollectorURL: "https://lambda-public.mxload.mx/put-request-log",
			ProjectID:    YOUR_PROJECT_ID, // Set your project ID
			ServiceKey:   "YOUR_SERVICE_KEY", // Set your service key
			CustomHeaders: []string{ // Set headers that should be sent to mxload.mx
				"Authorization",
			},
			IgnorePaths: []string{ // Set ignored paths
				"/ignored",
			},
		},
	))

    ....
}

echo

import (
    ...

    mxload "github.com/mxload/mxload_go"
)

func main() {
	e := echo.New()

	e.Use(echo.WrapMiddleware(mxload.MiddlewareFunc(
		&mxload.MxloadConfig{
			Enabled:      true,
			CollectorURL: "https://lambda-public.mxload.mx/put-request-log",
			ProjectID:    YOUR_PROJECT_ID,
			ServiceKey:   "YOUR_SERVICE_KEY",
			CustomHeaders: []string{
				"Authorization",
			},
			IgnorePaths: []string{
				"/ignored",
			},
		},
	)))
    ...
}

gin example

import (
	"net/http"

	"github.com/gin-gonic/gin"
	adapter "github.com/gwatts/gin-adapter"
	mxload "github.com/mxload/mxload_go"
)

func main() {
  r := gin.Default()

  r.Use(adapter.Wrap(mxload.MiddlewareFunc(
	&mxload.MxloadConfig{
		Enabled:      true,
		CollectorURL: "https://lambda-public.mxload.mx/put-request-log",
		ProjectID:    YOUR_PROJECT_ID,
		ServiceKey:   "YOUR_SERVICE_KEY",
		CustomHeaders: []string{
			"Authorization",
		},
		IgnorePaths: []string{
			"/ignored",
		},
	},
  )))
  ...
}

# Functions

No description provided by the author
No description provided by the author
No description provided by the author

# Structs

No description provided by the author
No description provided by the author
No description provided by the author