blob: 80ff32f61763494ef3682b746a5afce516e9c467 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
// Copyright 2020 The Gogs Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
package app
import (
"net/http"
"gopkg.in/macaron.v1"
"gogs.io/gogs/internal/conf"
"gogs.io/gogs/internal/context"
)
func MetricsFilter() macaron.Handler {
return func(c *context.Context) {
if !conf.Prometheus.Enabled {
c.Status(http.StatusNotFound)
return
}
if !conf.Prometheus.EnableBasicAuth {
return
}
c.RequireBasicAuth(conf.Prometheus.BasicAuthUsername, conf.Prometheus.BasicAuthPassword)
}
}
|