Lightweight Gin's middleware for request metrics
Download and install it:
$ go get github.com/newlode/gin-stats
import "github.com/newlode/gin-stats"
package main
import (
"fmt"
"time"
"github.com/gin-gonic/gin"
"github.com/newlode/gin-stats"
)
func main() {
r := gin.Default()
r.Use(stats.RequestStats())
r.GET("/stats", func(c *gin.Context) {
c.JSON(http.StatusOK, stats.Report())
})
// Listen and Server in 0.0.0.0:8080
r.Run(":8080")
}