1
0
mirror of https://github.com/muety/wakapi.git synced 2023-08-10 21:12:56 +03:00

chore: add check to validate wakatime api key before accepting it

This commit is contained in:
Ferdinand Mütsch
2021-01-30 10:54:54 +01:00
parent 417d4789ab
commit fd239e4f21
3 changed files with 47 additions and 7 deletions

View File

@ -13,11 +13,6 @@ import (
"time"
)
const (
WakatimeApiUrl = "https://wakatime.com/api/v1"
WakatimeApiHeartbeatsEndpoint = "/users/current/heartbeats.bulk"
)
/* Middleware to conditionally relay heartbeats to Wakatime */
type WakatimeRelayMiddleware struct {
httpClient *http.Client
@ -68,7 +63,7 @@ func (m *WakatimeRelayMiddleware) ServeHTTP(w http.ResponseWriter, r *http.Reque
go m.send(
http.MethodPost,
WakatimeApiUrl+WakatimeApiHeartbeatsEndpoint,
config.WakatimeApiUrl+config.WakatimeApiHeartbeatsEndpoint,
bytes.NewReader(body),
headers,
)