mirror of
https://github.com/foomo/contentfulproxy.git
synced 2025-10-16 12:25:37 +00:00
chore: fix linting problems
This commit is contained in:
parent
0668e3a09c
commit
13d94e64ed
4
go.mod
4
go.mod
@ -4,6 +4,8 @@ go 1.17
|
|||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/foomo/keel v0.3.1
|
github.com/foomo/keel v0.3.1
|
||||||
|
github.com/prometheus/client_golang v1.10.0
|
||||||
|
github.com/spf13/viper v1.7.1
|
||||||
github.com/stretchr/testify v1.7.0
|
github.com/stretchr/testify v1.7.0
|
||||||
go.uber.org/zap v1.19.1
|
go.uber.org/zap v1.19.1
|
||||||
)
|
)
|
||||||
@ -27,7 +29,6 @@ require (
|
|||||||
github.com/pelletier/go-toml v1.7.0 // indirect
|
github.com/pelletier/go-toml v1.7.0 // indirect
|
||||||
github.com/pkg/errors v0.9.1 // indirect
|
github.com/pkg/errors v0.9.1 // indirect
|
||||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||||
github.com/prometheus/client_golang v1.10.0 // indirect
|
|
||||||
github.com/prometheus/client_model v0.2.0 // indirect
|
github.com/prometheus/client_model v0.2.0 // indirect
|
||||||
github.com/prometheus/common v0.18.0 // indirect
|
github.com/prometheus/common v0.18.0 // indirect
|
||||||
github.com/prometheus/procfs v0.6.0 // indirect
|
github.com/prometheus/procfs v0.6.0 // indirect
|
||||||
@ -36,7 +37,6 @@ require (
|
|||||||
github.com/spf13/cast v1.3.0 // indirect
|
github.com/spf13/cast v1.3.0 // indirect
|
||||||
github.com/spf13/jwalterweatherman v1.0.0 // indirect
|
github.com/spf13/jwalterweatherman v1.0.0 // indirect
|
||||||
github.com/spf13/pflag v1.0.3 // indirect
|
github.com/spf13/pflag v1.0.3 // indirect
|
||||||
github.com/spf13/viper v1.7.1 // indirect
|
|
||||||
github.com/subosito/gotenv v1.2.0 // indirect
|
github.com/subosito/gotenv v1.2.0 // indirect
|
||||||
go.opentelemetry.io/contrib v0.20.0 // indirect
|
go.opentelemetry.io/contrib v0.20.0 // indirect
|
||||||
go.opentelemetry.io/contrib/instrumentation/host v0.20.0 // indirect
|
go.opentelemetry.io/contrib/instrumentation/host v0.20.0 // indirect
|
||||||
|
|||||||
@ -3,9 +3,10 @@ package proxy
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"github.com/foomo/contentfulproxy/packages/go/metrics"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/foomo/contentfulproxy/packages/go/metrics"
|
||||||
|
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
|
|
||||||
"github.com/foomo/contentfulproxy/packages/go/log"
|
"github.com/foomo/contentfulproxy/packages/go/log"
|
||||||
@ -21,7 +22,7 @@ type Info struct {
|
|||||||
type Metrics struct {
|
type Metrics struct {
|
||||||
NumUpdate prometheus.Counter
|
NumUpdate prometheus.Counter
|
||||||
NumProxyRequest prometheus.Counter
|
NumProxyRequest prometheus.Counter
|
||||||
NumApiRequest prometheus.Counter
|
NumAPIRequest prometheus.Counter
|
||||||
}
|
}
|
||||||
|
|
||||||
type Proxy struct {
|
type Proxy struct {
|
||||||
@ -71,7 +72,7 @@ func (p *Proxy) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
cachedResponse = jobDone.cachedResponse
|
cachedResponse = jobDone.cachedResponse
|
||||||
p.l.Info("serve response after cache creation", log.FURL(r.RequestURI), log.FCacheID(string(cacheID)))
|
p.l.Info("serve response after cache creation", log.FURL(r.RequestURI), log.FCacheID(string(cacheID)))
|
||||||
p.metrics.NumApiRequest.Inc()
|
p.metrics.NumAPIRequest.Inc()
|
||||||
} else {
|
} else {
|
||||||
p.l.Info("serve response from cache", log.FURL(r.RequestURI), log.FCacheID(string(cacheID)))
|
p.l.Info("serve response from cache", log.FURL(r.RequestURI), log.FCacheID(string(cacheID)))
|
||||||
}
|
}
|
||||||
@ -156,10 +157,11 @@ func jsonResponse(w http.ResponseWriter, v interface{}, statusCode int) {
|
|||||||
http.Error(w, "could not marshal info export", http.StatusInternalServerError)
|
http.Error(w, "could not marshal info export", http.StatusInternalServerError)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func getMetrics() *Metrics {
|
func getMetrics() *Metrics {
|
||||||
return &Metrics{
|
return &Metrics{
|
||||||
NumUpdate: metrics.NewCounter("numupdates", "number of times the update webhook was called"),
|
NumUpdate: metrics.NewCounter("numupdates", "number of times the update webhook was called"),
|
||||||
NumApiRequest: metrics.NewCounter("numapirequests", "number of times the proxy performed a contentful api-request"),
|
NumAPIRequest: metrics.NewCounter("numapirequests", "number of times the proxy performed a contentful api-request"),
|
||||||
NumProxyRequest: metrics.NewCounter("numproxyrequests", "number of times the proxy received an api-request"),
|
NumProxyRequest: metrics.NewCounter("numproxyrequests", "number of times the proxy received an api-request"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user