https://github.com/fatihkahveci/gin-inspector
Gin middleware for investigating http request.
https://github.com/fatihkahveci/gin-inspector
Last synced: 6 months ago
JSON representation
Gin middleware for investigating http request.
- Host: GitHub
- URL: https://github.com/fatihkahveci/gin-inspector
- Owner: fatihkahveci
- License: mit
- Created: 2019-02-08T11:54:04.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-02-08T21:52:11.000Z (over 7 years ago)
- Last Synced: 2025-05-12T20:42:38.967Z (about 1 year ago)
- Language: Go
- Size: 279 KB
- Stars: 43
- Watchers: 1
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-gin - fatihkahveci/gin-inspector
README
# Gin Inspector


Gin middleware for investigating http request.
## Usage
```sh
$ go get github.com/fatihkahveci/gin-inspector
```
### JSON Response
```
package main
import (
"github.com/fatihkahveci/gin-inspector"
"github.com/gin-gonic/gin"
)
func main() {
r := gin.Default()
debug := true
if debug {
r.Use(inspector.InspectorStats())
r.GET("/_inspector", func(c *gin.Context) {
c.JSON(200, inspector.GetPaginator())
})
}
r.Run()
}
```
### Html Template
```
package main
import (
"html/template"
"net/http"
"time"
"github.com/fatihkahveci/gin-inspector"
"github.com/gin-gonic/gin"
)
func formatDate(t time.Time) string {
return t.Format(time.RFC822)
}
func main() {
r := gin.Default()
r.Delims("{{", "}}")
r.SetFuncMap(template.FuncMap{
"formatDate": formatDate,
})
r.LoadHTMLFiles("inspector.html")
debug := true
if debug {
r.Use(inspector.InspectorStats())
r.GET("/_inspector", func(c *gin.Context) {
c.HTML(http.StatusOK, "inspector.html", map[string]interface{}{
"title": "Gin Inspector",
"pagination": inspector.GetPaginator(),
})
})
}
r.Run(":8080")
}
```