[golang] bootstrapped a client in yet another language
This commit is contained in:
parent
5aac233c08
commit
427cc77fa3
12 changed files with 447 additions and 0 deletions
23
golang/pkg/api/errors.go
Normal file
23
golang/pkg/api/errors.go
Normal file
|
@ -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
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue