Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fatihkahveci/gin-inspector
Gin middleware for investigating http request.
https://github.com/fatihkahveci/gin-inspector
Last synced: 2 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 (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2019-02-08T21:52:11.000Z (almost 6 years ago)
- Last Synced: 2024-02-14T19:32:47.106Z (12 months ago)
- Language: Go
- Size: 279 KB
- Stars: 42
- Watchers: 2
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-gin - fatihkahveci/gin-inspector
README
# Gin Inspector
![Gin Inspector HTML Preview](https://raw.githubusercontent.com/fatihkahveci/gin-inspector/master/preview-html.png)
![Gin Inspector HTML Preview 2](https://raw.githubusercontent.com/fatihkahveci/gin-inspector/master/preview-html-2.jpg)
Gin middleware for investigating http request.
## Usage
```sh
$ go get github.com/fatihkahveci/gin-inspector
```### JSON Response
```
package mainimport (
"github.com/fatihkahveci/gin-inspector"
"github.com/gin-gonic/gin"
)func main() {
r := gin.Default()
debug := trueif debug {
r.Use(inspector.InspectorStats())
r.GET("/_inspector", func(c *gin.Context) {
c.JSON(200, inspector.GetPaginator())
})
}r.Run()
}
```### Html Template
```
package mainimport (
"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 := trueif 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")
}```