Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/semihalev/gin-stats
Gin's middleware for request stats
https://github.com/semihalev/gin-stats
gin gin-gonic gin-middleware metrics middleware stats
Last synced: 3 months ago
JSON representation
Gin's middleware for request stats
- Host: GitHub
- URL: https://github.com/semihalev/gin-stats
- Owner: semihalev
- License: mit
- Created: 2018-05-05T15:29:57.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-07-10T00:27:58.000Z (over 4 years ago)
- Last Synced: 2024-02-14T19:32:55.059Z (11 months ago)
- Topics: gin, gin-gonic, gin-middleware, metrics, middleware, stats
- Language: Go
- Size: 3.91 KB
- Stars: 34
- Watchers: 4
- Forks: 10
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-gin - semihalev/gin-stats
README
# Gin's middleware for request stats
[![Build Status](https://travis-ci.org/semihalev/gin-stats.svg)](https://travis-ci.org/semihalev/gin-stats)
[![codecov](https://codecov.io/gh/semihalev/gin-stats/branch/master/graph/badge.svg)](https://codecov.io/gh/semihalev/gin-stats)
[![Go Report Card](https://goreportcard.com/badge/github.com/semihalev/gin-stats)](https://goreportcard.com/report/github.com/semihalev/gin-stats)
[![GoDoc](https://godoc.org/github.com/semihalev/gin-stats?status.svg)](https://godoc.org/github.com/semihalev/gin-stats)Lightweight Gin's middleware for request metrics
## Usage
### Start using it
Download and install it:
```sh
$ go get github.com/semihalev/gin-stats
``````go
import "github.com/semihalev/gin-stats"
```### Example usage:
```go
package mainimport (
"fmt"
"time""github.com/gin-gonic/gin"
"github.com/semihalev/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")
}```