Reviewed-on: tim/me-fit#69
This commit is contained in:
@@ -10,10 +10,24 @@ import (
|
||||
"time"
|
||||
|
||||
"firebase.google.com/go/auth"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/prometheus/client_golang/prometheus/promauto"
|
||||
)
|
||||
|
||||
var (
|
||||
metrics = promauto.NewCounterVec(
|
||||
prometheus.CounterOpts{
|
||||
Name: "mefit_api_workout_total",
|
||||
Help: "The total number of workout api requests processed",
|
||||
},
|
||||
[]string{"type"},
|
||||
)
|
||||
)
|
||||
|
||||
func NewWorkout(db *sql.DB) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
metrics.WithLabelValues("new").Inc()
|
||||
|
||||
var dateStr = r.FormValue("date")
|
||||
var typeStr = r.FormValue("type")
|
||||
var setsStr = r.FormValue("sets")
|
||||
@@ -55,6 +69,8 @@ func NewWorkout(db *sql.DB) http.HandlerFunc {
|
||||
|
||||
func GetWorkouts(db *sql.DB) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
metrics.WithLabelValues("get").Inc()
|
||||
|
||||
token := r.Context().Value(middleware.TOKEN_KEY).(*auth.Token)
|
||||
var userId = token.UID
|
||||
|
||||
@@ -94,6 +110,8 @@ func GetWorkouts(db *sql.DB) http.HandlerFunc {
|
||||
|
||||
func DeleteWorkout(db *sql.DB) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
metrics.WithLabelValues("delete").Inc()
|
||||
|
||||
token := r.Context().Value(middleware.TOKEN_KEY).(*auth.Token)
|
||||
var userId = token.UID
|
||||
|
||||
|
||||
Reference in New Issue
Block a user