aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/gitea.com/macaron/toolbox/README.md
diff options
context:
space:
mode:
authorTamal Saha <tamal@appscode.com>2019-08-23 09:40:30 -0700
committertechknowlogick <techknowlogick@gitea.io>2019-08-23 12:40:29 -0400
commit171b3598778a1ecd0a921c71ed6755bfef68f7f0 (patch)
tree02857629ef9e8e26ee0ee559153f803f77b588b7 /vendor/gitea.com/macaron/toolbox/README.md
parentca6fb004ac50fc924861112403895d637c6a2d1d (diff)
downloadgitea-171b3598778a1ecd0a921c71ed6755bfef68f7f0.tar.gz
gitea-171b3598778a1ecd0a921c71ed6755bfef68f7f0.zip
Use gitea forked macaron (#7933)
Signed-off-by: Tamal Saha <tamal@appscode.com>
Diffstat (limited to 'vendor/gitea.com/macaron/toolbox/README.md')
-rw-r--r--vendor/gitea.com/macaron/toolbox/README.md112
1 files changed, 112 insertions, 0 deletions
diff --git a/vendor/gitea.com/macaron/toolbox/README.md b/vendor/gitea.com/macaron/toolbox/README.md
new file mode 100644
index 0000000000..75055d5f07
--- /dev/null
+++ b/vendor/gitea.com/macaron/toolbox/README.md
@@ -0,0 +1,112 @@
+toolbox
+=======
+
+Middleware toolbox provides health chcek, pprof, profile and statistic services for [Macaron](https://gitea.com/macaron/macaron).
+
+[![Build Status](https://drone.gitea.com/api/badges/macaron/toolbox/status.svg)](https://drone.gitea.com/macaron/toolbox)
+[API Reference](https://gowalker.org/gitea.com/macaron/toolbox)
+
+### Installation
+
+ go get gitea.com/macaron/toolbox
+
+## Usage
+
+```go
+// main.go
+import (
+ "gitea.com/macaron/macaron"
+ "gitea.com/macaron/toolbox"
+)
+
+func main() {
+ m := macaron.Classic()
+ m.Use(toolbox.Toolboxer(m))
+ m.Run()
+}
+```
+
+Open your browser and visit `http://localhost:4000/debug` to see the effects.
+
+## Options
+
+`toolbox.Toolboxer` comes with a variety of configuration options:
+
+```go
+type dummyChecker struct {
+}
+
+func (dc *dummyChecker) Desc() string {
+ return "Dummy checker"
+}
+
+func (dc *dummyChecker) Check() error {
+ return nil
+}
+
+// ...
+m.Use(toolbox.Toolboxer(m, toolbox.Options{
+ URLPrefix: "/debug", // URL prefix for toolbox dashboard
+ HealthCheckURL: "/healthcheck", // URL for health check request
+ HealthCheckers: []HealthChecker{
+ new(dummyChecker),
+ }, // Health checkers
+ HealthCheckFuncs: []*toolbox.HealthCheckFuncDesc{
+ &toolbox.HealthCheckFuncDesc{
+ Desc: "Database connection",
+ Func: func() error { return "OK" },
+ },
+ }, // Health check functions
+ DisableDebug: false, // Turns off all debug functionality when true
+ PprofURLPrefix: "/debug/pprof/", // URL prefix of pprof
+ ProfileURLPrefix: "/debug/profile/", // URL prefix of profile
+ ProfilePath: "profile", // Path store profile files
+}))
+// ...
+```
+
+## Route Statistic
+
+Toolbox also comes with a route call statistic functionality:
+
+```go
+import (
+ "os"
+ "time"
+ //...
+ "gitea.com/macaron/toolbox"
+)
+
+func main() {
+ //...
+ m.Get("/", func(t toolbox.Toolbox) {
+ start := time.Now()
+
+ // Other operations.
+
+ t.AddStatistics("GET", "/", time.Since(start))
+ })
+
+ m.Get("/dump", func(t toolbox.Toolbox) {
+ t.GetMap(os.Stdout)
+ })
+}
+```
+
+Output take from test:
+
+```
++---------------------------------------------------+------------+------------------+------------------+------------------+------------------+------------------+
+| Request URL | Method | Times | Total Used(s) | Max Used(μs) | Min Used(μs) | Avg Used(μs) |
++---------------------------------------------------+------------+------------------+------------------+------------------+------------------+------------------+
+| /api/user | POST | 2 | 0.000122 | 120.000000 | 2.000000 | 61.000000 |
+| /api/user | GET | 1 | 0.000013 | 13.000000 | 13.000000 | 13.000000 |
+| /api/user | DELETE | 1 | 0.000001 | 1.400000 | 1.400000 | 1.400000 |
+| /api/admin | POST | 1 | 0.000014 | 14.000000 | 14.000000 | 14.000000 |
+| /api/user/unknwon | POST | 1 | 0.000012 | 12.000000 | 12.000000 | 12.000000 |
++---------------------------------------------------+------------+------------------+------------------+------------------+------------------+------------------+
+```
+
+## License
+
+This project is under Apache v2 License. See the [LICENSE](LICENSE) file for the full license text. \ No newline at end of file