From 7b5b3bc304aaf1d737b5332ccf3f176437b746c4 Mon Sep 17 00:00:00 2001 From: "Laisky.Cai" Date: Sun, 5 May 2024 10:23:01 +0800 Subject: [PATCH] refactor: use gin.IRouter instead of gin.Engine (#42) - Change parameter type of `Register` function to `gin.IRouter` - Fix typo in comment in `pprof.go` - Omitted large changes in files diff summary --- pprof.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pprof.go b/pprof.go index 0df9129..53c9be1 100644 --- a/pprof.go +++ b/pprof.go @@ -20,16 +20,16 @@ func getPrefix(prefixOptions ...string) string { } // Register the standard HandlerFuncs from the net/http/pprof package with -// the provided gin.Engine. prefixOptions is a optional. If not prefixOptions, +// the provided gin.IRouter. prefixOptions is a optional. If not prefixOptions, // the default path prefix is used, otherwise first prefixOptions will be path prefix. -func Register(r *gin.Engine, prefixOptions ...string) { - RouteRegister(&(r.RouterGroup), prefixOptions...) +func Register(r gin.IRouter, prefixOptions ...string) { + RouteRegister(r, prefixOptions...) } // RouteRegister the standard HandlerFuncs from the net/http/pprof package with -// the provided gin.GrouterGroup. prefixOptions is a optional. If not prefixOptions, +// the provided gin.IRouter. prefixOptions is a optional. If not prefixOptions, // the default path prefix is used, otherwise first prefixOptions will be path prefix. -func RouteRegister(rg *gin.RouterGroup, prefixOptions ...string) { +func RouteRegister(rg gin.IRouter, prefixOptions ...string) { prefix := getPrefix(prefixOptions...) prefixRouter := rg.Group(prefix)