Gin middleware for investigating http request.
Branch: master
Clone or download
Latest commit ffbe3a2 Feb 8, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
examples add preview detail Feb 8, 2019
LICENSE Initial commit Feb 8, 2019
README.md add preview detail Feb 8, 2019
inspector.go first commit Feb 8, 2019
preview-html-2.jpg add preview detail Feb 8, 2019
preview-html.png preview added Feb 8, 2019

README.md

Gin Inspector

Gin Inspector HTML Preview

Gin Inspector HTML Preview 2

Gin middleware for investigating http request.

Usage

$ 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")
}