https://github.com/iamgoroot/gin-endpoint-usage
https://github.com/iamgoroot/gin-endpoint-usage
Last synced: 6 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/iamgoroot/gin-endpoint-usage
- Owner: iamgoroot
- Created: 2024-10-11T21:08:14.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-10-23T07:22:07.000Z (over 1 year ago)
- Last Synced: 2024-10-24T19:01:34.155Z (over 1 year ago)
- Language: Go
- Size: 14.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# gin-usage-stats
A simple middleware for Gin that allows you to collect usage statistics for your endpoints to find unused endpoints.
It's intended to use this on your test server while running your autotests.
For production monitoring use prometheus libs for example https://github.com/penglongli/gin-metrics
## Installation
You can install the package via go get:
```golang
go get github.com/iamgoroot/gin-endpoint-usage
```
## Usage
You can setup it directly in your Gin application as follows:
```golang
package main
import (
"github.com/gin-gonic/gin"
"github.com/iamgoroot/gin-endpoint-usage"
)
func main() {
router := gin.Default()
rdb := redis.NewClient(&redis.Options{ /* redis options */ })
stats := &StatMiddleware{Backend: &RedisBackend{RedisClient: rdb}}
stats.Setup(router)
router.Run(":8080")
}
```
get the stats via endpoints
`http://localhost:8080/endpoint-usage-stats` for html table
`http://localhost:8080/endpoint-usage-stats/json` for json
`http://localhost:8080/endpoint-usage-stats/csv` for csv
`http://localhost:8080/endpoint-usage-stats/xml` for xml