{"id":18781123,"url":"https://github.com/go-macaron/toolbox","last_synced_at":"2025-04-13T11:31:16.810Z","repository":{"id":19423846,"uuid":"22666405","full_name":"go-macaron/toolbox","owner":"go-macaron","description":"Package toolbox is a middleware that provides health check, pprof, profile and statistic services for Macaron.","archived":false,"fork":false,"pushed_at":"2020-03-31T09:32:09.000Z","size":31,"stargazers_count":20,"open_issues_count":0,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-27T03:01:48.001Z","etag":null,"topics":["go","lsif-enabled","macaron","middleware","toolbox"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/go-macaron.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-08-06T02:07:10.000Z","updated_at":"2024-06-06T20:56:35.000Z","dependencies_parsed_at":"2022-07-27T00:32:04.092Z","dependency_job_id":null,"html_url":"https://github.com/go-macaron/toolbox","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/go-macaron%2Ftoolbox","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/go-macaron%2Ftoolbox/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/go-macaron%2Ftoolbox/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/go-macaron%2Ftoolbox/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/go-macaron","download_url":"https://codeload.github.com/go-macaron/toolbox/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248705596,"owners_count":21148559,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["go","lsif-enabled","macaron","middleware","toolbox"],"created_at":"2024-11-07T20:29:39.587Z","updated_at":"2025-04-13T11:31:16.557Z","avatar_url":"https://github.com/go-macaron.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# toolbox\n\n[![GitHub Workflow Status](https://img.shields.io/github/workflow/status/go-macaron/toolbox/Go?logo=github\u0026style=for-the-badge)](https://github.com/go-macaron/toolbox/actions?query=workflow%3AGo)\n[![codecov](https://img.shields.io/codecov/c/github/go-macaron/toolbox/master?logo=codecov\u0026style=for-the-badge)](https://codecov.io/gh/go-macaron/toolbox)\n[![GoDoc](https://img.shields.io/badge/GoDoc-Reference-blue?style=for-the-badge\u0026logo=go)](https://pkg.go.dev/github.com/go-macaron/toolbox?tab=doc)\n[![Sourcegraph](https://img.shields.io/badge/view%20on-Sourcegraph-brightgreen.svg?style=for-the-badge\u0026logo=sourcegraph)](https://sourcegraph.com/github.com/go-macaron/toolbox)\n\nMiddleware toolbox provides health chcek, pprof, profile and statistic services for [Macaron](https://github.com/go-macaron/macaron).\n\n[API Reference](https://gowalker.org/github.com/go-macaron/toolbox)\n\n### Installation\n\n\tgo get github.com/go-macaron/toolbox\n\t\n## Usage\n\n```go\n// main.go\nimport (\n\t\"gopkg.in/macaron.v1\"\n\t\"github.com/go-macaron/toolbox\"\n)\n\nfunc main() {\n  \tm := macaron.Classic()\n  \tm.Use(toolbox.Toolboxer(m))\n\tm.Run()\n}\n```\n\nOpen your browser and visit `http://localhost:4000/debug` to see the effects.\n\n## Options\n\n`toolbox.Toolboxer` comes with a variety of configuration options:\n\n```go\ntype dummyChecker struct {\n}\n\nfunc (dc *dummyChecker) Desc() string {\n\treturn \"Dummy checker\"\n}\n\nfunc (dc *dummyChecker) Check() error {\n\treturn nil\n}\n\n// ...\nm.Use(toolbox.Toolboxer(m, toolbox.Options{\n\tURLPrefix:\t\t\t\"/debug\",\t\t\t// URL prefix for toolbox dashboard\n\tHealthCheckURL:\t\t\"/healthcheck\", \t// URL for health check request\n\tHealthCheckers: []HealthChecker{\n\t\tnew(dummyChecker),\n\t},\t\t\t\t\t\t\t\t\t\t// Health checkers\n\tHealthCheckFuncs: []*toolbox.HealthCheckFuncDesc{\n\t\t\u0026toolbox.HealthCheckFuncDesc{\n\t\t\tDesc: \"Database connection\",\n\t\t\tFunc: func() error { return \"OK\" },\n\t\t},\n\t},\t\t\t\t\t\t\t\t\t\t// Health check functions\n\tDisableDebug:\t\tfalse,\t\t\t\t// Turns off all debug functionality when true\n\tPprofURLPrefix:\t\t\"/debug/pprof/\", \t// URL prefix of pprof\n\tProfileURLPrefix:\t\"/debug/profile/\", \t// URL prefix of profile\n\tProfilePath:\t\t\"profile\",\t\t\t// Path store profile files\n}))\n// ...\n```\n\n## Route Statistic\n\nToolbox also comes with a route call statistic functionality:\n\n```go\nimport (\n\t\"os\"\n\t\"time\"\n\t//...\n\t\"github.com/go-macaron/toolbox\"\n)\n\nfunc main() {\n\t//...\n\tm.Get(\"/\", func(t toolbox.Toolbox) {\n\t\tstart := time.Now()\n\t\t\n\t\t// Other operations.\n\t\t\n\t\tt.AddStatistics(\"GET\", \"/\", time.Since(start))\n\t})\n\t\n\tm.Get(\"/dump\", func(t toolbox.Toolbox) {\n\t\tt.GetMap(os.Stdout)\n\t})\n}\n```\n\nOutput take from test:\n\n```\n+---------------------------------------------------+------------+------------------+------------------+------------------+------------------+------------------+\n| Request URL                                       | Method     | Times            | Total Used(s)    | Max Used(μs)     | Min Used(μs)     | Avg Used(μs)     |\n+---------------------------------------------------+------------+------------------+------------------+------------------+------------------+------------------+\n| /api/user                                         | POST       |                2 |         0.000122 |       120.000000 |         2.000000 |        61.000000 |\n| /api/user                                         | GET        |                1 |         0.000013 |        13.000000 |        13.000000 |        13.000000 |\n| /api/user                                         | DELETE     |                1 |         0.000001 |         1.400000 |         1.400000 |         1.400000 |\n| /api/admin                                        | POST       |                1 |         0.000014 |        14.000000 |        14.000000 |        14.000000 |\n| /api/user/unknwon                                 | POST       |                1 |         0.000012 |        12.000000 |        12.000000 |        12.000000 |\n+---------------------------------------------------+------------+------------------+------------------+------------------+------------------+------------------+\n```\n\n## License\n\nThis project is under Apache v2 License. See the [LICENSE](LICENSE) file for the full license text.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgo-macaron%2Ftoolbox","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgo-macaron%2Ftoolbox","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgo-macaron%2Ftoolbox/lists"}