1
0

gin.go 533 B

1234567891011121314151617181920212223242526272829303132
  1. package transfer
  2. import (
  3. "net/http"
  4. "github.com/gin-gonic/gin"
  5. )
  6. /**
  7. e.g.
  8. package main
  9. import (
  10. "github.com/gin-gonic/gin"
  11. "gogs.baozhida.cn/zoie/OAuth-core/transfer"
  12. "github.com/prometheus/client_golang/prometheus/promhttp"
  13. )
  14. func main() {
  15. r := gin.Default()
  16. r.GET("/monitor", transfer.Handler(promhttp.Handler()))
  17. r.Run(":9999")
  18. }
  19. **/
  20. // Handler http.Handler 转换成 gin.HandlerFunc
  21. func Handler(handler http.Handler) gin.HandlerFunc {
  22. return func(c *gin.Context) {
  23. handler.ServeHTTP(c.Writer, c.Request)
  24. }
  25. }