github.com/gofiber/fiber/v2@v2.47.0/docs/api/middleware/expvar.md (about) 1 --- 2 id: expvar 3 title: ExpVar 4 --- 5 6 Expvar middleware for [Fiber](https://github.com/gofiber/fiber) that serves via its HTTP server runtime exposed variants in the JSON format. The package is typically only imported for the side effect of registering its HTTP handlers. The handled path is `/debug/vars`. 7 8 ## Signatures 9 10 ```go 11 func New() fiber.Handler 12 ``` 13 14 ## Examples 15 16 Import the middleware package that is part of the Fiber web framework 17 18 ```go 19 import ( 20 "github.com/gofiber/fiber/v2" 21 expvarmw "github.com/gofiber/fiber/v2/middleware/expvar" 22 ) 23 ``` 24 25 After you initiate your Fiber app, you can use the following possibilities: 26 ```go 27 var count = expvar.NewInt("count") 28 29 app.Use(expvarmw.New()) 30 app.Get("/", func(c *fiber.Ctx) error { 31 count.Add(1) 32 33 return c.SendString(fmt.Sprintf("hello expvar count %d", count.Value())) 34 }) 35 ``` 36 37 Visit path `/debug/vars` to see all vars and use query `r=key` to filter exposed variables. 38 39 ```bash 40 curl 127.0.0.1:3000 41 hello expvar count 1 42 43 curl 127.0.0.1:3000/debug/vars 44 { 45 "cmdline": ["xxx"], 46 "count": 1, 47 "expvarHandlerCalls": 33, 48 "expvarRegexpErrors": 0, 49 "memstats": {...} 50 } 51 52 curl 127.0.0.1:3000/debug/vars?r=c 53 { 54 "cmdline": ["xxx"], 55 "count": 1 56 } 57 ``` 58 59 ## Config 60 61 ```go 62 // Config defines the config for middleware. 63 type Config struct { 64 // Next defines a function to skip this middleware when returned true. 65 // 66 // Optional. Default: nil 67 Next func(c *fiber.Ctx) bool 68 } 69 ``` 70 71 ## Default Config 72 73 ```go 74 var ConfigDefault = Config{ 75 Next: nil, 76 } 77 ```