Replace prazdnikisegodnyaru with celebratoday, small underhood fixes
- Replace prazdnikisegodnyaru with celebratoday as first is banned in Russia - Update .golangci.yml rule set - Megatons of fixes for linter - Update README.md
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
// Package thecatapi implements api.thecatapi.com service client.
|
||||
package thecatapi
|
||||
|
||||
import (
|
||||
@@ -9,16 +10,18 @@ import (
|
||||
"github.com/carlmjohnson/requests"
|
||||
)
|
||||
|
||||
// TheCatAPIinnerStruct структурка, описывающая элемент массива, возвращемый Тhe cat api.
|
||||
type TheCatAPIinnerStruct struct {
|
||||
ID string `json:"id,omitempty"`
|
||||
URL string `json:"url"`
|
||||
Width int `json:"width,omitempty"`
|
||||
Height int `json:"height,omitempty"`
|
||||
}
|
||||
type (
|
||||
// TheCatAPIinnerStruct структурка, описывающая элемент массива, возвращемый Тhe cat api.
|
||||
TheCatAPIinnerStruct struct {
|
||||
ID string `json:"id,omitempty"`
|
||||
URL string `json:"url"`
|
||||
Width int `json:"width,omitempty"`
|
||||
Height int `json:"height,omitempty"`
|
||||
}
|
||||
|
||||
// TheCatAPI структурка, описывающая массив, возвращаемый на запрос урла картинки из The Cat API.
|
||||
type TheCatAPI []TheCatAPIinnerStruct
|
||||
// TheCatAPI структурка, описывающая массив, возвращаемый на запрос урла картинки из The Cat API.
|
||||
TheCatAPI []TheCatAPIinnerStruct
|
||||
)
|
||||
|
||||
// APIClient клиент сервиса thecatapi.com.
|
||||
func APIClient(cfg *config.MyConfig) (string, error) {
|
||||
@@ -29,11 +32,7 @@ func APIClient(cfg *config.MyConfig) (string, error) {
|
||||
cat TheCatAPI
|
||||
)
|
||||
|
||||
err := requests.
|
||||
URL(url).
|
||||
UserAgent(userAgent).
|
||||
ToJSON(&cat).
|
||||
Fetch(ctx)
|
||||
err := requests.URL(url).UserAgent(userAgent).ToJSON(&cat).Fetch(ctx)
|
||||
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("unable to GET %s: %w", url, err)
|
||||
|
||||
Reference in New Issue
Block a user