eia-api-go/pkg/eia/eia_health.go

21 lines
335 B
Go
Raw Normal View History

2024-11-16 19:02:46 +00:00
package eia
import (
"context"
"fmt"
)
func (c *Client) Ping() error {
ctx, cncl := context.WithTimeout(c.ctx, c.healthCheckTimeout)
defer cncl()
resp, err := c.GetV2(ctx)
if err != nil {
return err
} else if resp.StatusCode != 200 {
return fmt.Errorf("non-200 response [%s] from eia api", resp.Status)
}
return nil
}