From 427cc77fa3633aca7c4c3377fa26b0e70921a7b5 Mon Sep 17 00:00:00 2001 From: Julien Dessaux Date: Mon, 6 May 2024 00:18:22 +0200 Subject: [golang] bootstrapped a client in yet another language --- golang/pkg/api/errors.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 golang/pkg/api/errors.go (limited to 'golang/pkg/api/errors.go') diff --git a/golang/pkg/api/errors.go b/golang/pkg/api/errors.go new file mode 100644 index 0000000..d39a205 --- /dev/null +++ b/golang/pkg/api/errors.go @@ -0,0 +1,23 @@ +package api + +import ( + "encoding/json" + "fmt" + "time" +) + +type RateLimitError struct { + LimitType string `json:"type"` + RetryAfter float64 `json:"retryAfter"` + LimitBurst int `json:"limitBurst"` + LimitPerSecond int `json:"limitPerSecond"` + Remaining int `json:"remaining"` + Reset time.Time `json:"reset"` +} + +func decode429(msg []byte) (e APIMessage[any, RateLimitError]) { + if err := json.Unmarshal(msg, &e); err != nil { + panic(fmt.Sprintf("Failed to decode419: %+v", err)) + } + return e +} -- cgit v1.2.3