gorilla/mux

Configure Scout in your Gorilla Mux application in 1 minute or less

We recommending integrating the Scout Gorilla Mux middleware in your Gorilla Mux applications.

The Gorilla Mux middleware will record key attributes for your API requests (such as client IPs and status codes).

The examples in this section assume that you already know how to initialise Scout in your Go applications. If you do not know how, or if you would like a refresher, click here.
  1. If your backend exposes APIs to your frontend application, start by initialising Scout in your frontend with the following configuration:
const SCOUT_PROJECT_ID = process.env.SCOUT_PROJECT_ID

Scout.init(SCOUT_PROJECT_ID, {
  // any backend deployments should go here
  tracingOrigins: ['localhost', 'your-app.com/backend'],
  networkRecording: {
    enabled: true,
    recordHeadersAndBody: true,
  },
  // ... extra Scout configs
})
  1. Configure Scout in your Gorilla Mux backend:
func main() {
    scout.Init(
        ...
    )
    defer scout.Stop()
}
  1. Integrate the Gorilla Mux middleware:
import (
    ...
    scoutMux "github.com/scout-inc/scout-go/middleware/gorillamux"
)

func main() {
    // ...
    r := mux.NewRouter()
    r.Use(scoutMux.Middleware)
    // ...
}