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