aboutsummaryrefslogtreecommitdiff
path: root/instance.go
diff options
context:
space:
mode:
authorRasmus Dahlberg <rasmus.dahlberg@kau.se>2021-03-15 20:18:29 +0100
committerRasmus Dahlberg <rasmus.dahlberg@kau.se>2021-03-15 20:18:29 +0100
commite2959d506de6067afe494315c3621b33613b5414 (patch)
treedb51eb9917760717156f8e9cfebccdd6e1d51a1c /instance.go
parent864031a77981d970f7e3fd89380a7bdb42d70d33 (diff)
added option to run with unregistered namespaces
Also a few minor fixes such that server binary starts again.
Diffstat (limited to 'instance.go')
-rw-r--r--instance.go11
1 files changed, 8 insertions, 3 deletions
diff --git a/instance.go b/instance.go
index 6f1314b..67336f8 100644
--- a/instance.go
+++ b/instance.go
@@ -41,16 +41,21 @@ type Handler struct {
Handler func(context.Context, *Instance, http.ResponseWriter, *http.Request) (int, error)
}
+// Path returns a path that should be configured for this handler
+func (h Handler) Path() string {
+ return h.Endpoint.Path("", h.Instance.LogParameters.Prefix)
+}
+
// ServeHTTP is part of the http.Handler interface
func (a Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
// export prometheus metrics
var now time.Time = time.Now()
var statusCode int
defer func() {
- rspcnt.Inc(string(a.Instance.LogParameters.LogIdBytes), string(a.Endpoint), fmt.Sprintf("%d", statusCode))
- latency.Observe(time.Now().Sub(now).Seconds(), string(a.Instance.LogParameters.LogIdBytes), string(a.Endpoint), fmt.Sprintf("%d", statusCode))
+ rspcnt.Inc(a.Instance.LogParameters.LogIdStr, string(a.Endpoint), fmt.Sprintf("%d", statusCode))
+ latency.Observe(time.Now().Sub(now).Seconds(), a.Instance.LogParameters.LogIdStr, string(a.Endpoint), fmt.Sprintf("%d", statusCode))
}()
- reqcnt.Inc(string(a.Instance.LogParameters.LogIdBytes), string(a.Endpoint))
+ reqcnt.Inc(a.Instance.LogParameters.LogIdStr, string(a.Endpoint))
ctx, cancel := context.WithDeadline(r.Context(), now.Add(a.Instance.LogParameters.Deadline))
defer cancel()