Clean up code, remove Prometheus

This commit is contained in:
Jacob Gunther
2022-07-11 11:27:43 -05:00
parent a87b633ca3
commit 57b8b17e42
10 changed files with 98 additions and 381 deletions

View File

@@ -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
}