Clean up code, remove Prometheus
This commit is contained in:
@@ -1,41 +1,25 @@
|
||||
package routes
|
||||
|
||||
import (
|
||||
"log"
|
||||
"net/http"
|
||||
|
||||
"github.com/mineatar-io/api-server/src/util"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/prometheus/client_golang/prometheus/promauto"
|
||||
"github.com/valyala/fasthttp"
|
||||
)
|
||||
|
||||
var (
|
||||
uuidLookupMetric = promauto.NewCounter(prometheus.CounterOpts{
|
||||
Name: "uuid_lookup_request_count",
|
||||
Help: "The amount of UUID lookup requests",
|
||||
})
|
||||
)
|
||||
|
||||
func UUIDHandler(ctx *fasthttp.RequestCtx) {
|
||||
user := ctx.UserValue("user").(string)
|
||||
|
||||
uuid, ok, err := util.LookupUUID(user)
|
||||
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
|
||||
ctx.SetStatusCode(http.StatusInternalServerError)
|
||||
ctx.SetBodyString(http.StatusText(http.StatusInternalServerError))
|
||||
util.WriteError(ctx, err, http.StatusInternalServerError)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
uuidLookupMetric.Inc()
|
||||
|
||||
if !ok {
|
||||
ctx.SetStatusCode(404)
|
||||
ctx.SetBodyString(http.StatusText(http.StatusNotFound))
|
||||
util.WriteError(ctx, nil, http.StatusNotFound)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user