Gin middleware for investigating http request.
$ go get github.com/fatihkahveci/gin-inspector
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()
}
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")
}