go-chi/chi
Configure Scout in your go-chi application in 1 minute or less
We recommending integrating the Scout Chi middleware in your Chi applications.
The Chi 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.
- 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
})
- Configure Scout in your Chi backend:
func main() {
scout.Init(
...
)
defer scout.Stop()
}
- Integrate the go-chi middleware:
import (
...
scoutChi "github.com/scout-inc/scout-go/middleware/chi"
)
func main() {
// ...
r := chi.NewRouter()
r.Use(scoutChi.Middleware)
// ...
}