diff options
author | 2016-04-06 09:21:46 +0100 | |
---|---|---|
committer | 2016-04-06 09:21:46 +0100 | |
commit | 68171c7a638a4087deac495b39ca7f539ed93673 (patch) | |
tree | 8844c95249964d57122d1fc779882515d6f4f5f8 /core/setup/health.go | |
parent | ecb53addd6f76206e6070e2312d6a48435c450e7 (diff) | |
download | coredns-68171c7a638a4087deac495b39ca7f539ed93673.tar.gz coredns-68171c7a638a4087deac495b39ca7f539ed93673.tar.zst coredns-68171c7a638a4087deac495b39ca7f539ed93673.zip |
A health middleware
Start http handler on port 8080 and return OK. Also add some
documentation fixes for the prometheus middleware.
Diffstat (limited to 'core/setup/health.go')
-rw-r--r-- | core/setup/health.go | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/core/setup/health.go b/core/setup/health.go new file mode 100644 index 000000000..608147b13 --- /dev/null +++ b/core/setup/health.go @@ -0,0 +1,33 @@ +package setup + +import ( + "github.com/miekg/coredns/middleware" + "github.com/miekg/coredns/middleware/health" +) + +func Health(c *Controller) (middleware.Middleware, error) { + addr, err := parseHealth(c) + if err != nil { + return nil, err + } + + h := health.Health{Addr: addr} + c.Startup = append(c.Startup, h.ListenAndServe) + return nil, nil +} + +func parseHealth(c *Controller) (string, error) { + addr := "" + for c.Next() { + args := c.RemainingArgs() + + switch len(args) { + case 0: + case 1: + addr = args[0] + default: + return "", c.ArgErr() + } + } + return addr, nil +} |