Skip to content

Commit

Permalink
Merge pull request #50 from G-Core/feature/CDI-468_add_origin_shielding
Browse files Browse the repository at this point in the history
CDI-468: fix get shielding locations method
  • Loading branch information
anton-sharonov authored Feb 21, 2024
2 parents b9d8157 + 3da49d3 commit 0b2a40f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion originshielding/originshielding.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
type OriginShieldingService interface {
Update(ctx context.Context, id int64, req *UpdateRequest) (*OriginShieldingData, error)
Get(ctx context.Context, id int64) (*OriginShieldingData, error)
GetLocations(ctx context.Context) (*OriginShieldingLocations, error)
GetLocations(ctx context.Context) ([]OriginShieldingLocations, error)
}

type OriginShieldingData struct {
Expand Down
20 changes: 10 additions & 10 deletions originshielding/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,28 @@ func NewService(r gcore.Requester) *Service {
}

func (s *Service) Update(ctx context.Context, id int64, req *UpdateRequest) (*OriginShieldingData, error) {
var origin_shielding OriginShieldingData
if err := s.r.Request(ctx, http.MethodPut, fmt.Sprintf("/cdn/resources/%d/shielding_v2", id), req, &origin_shielding); err != nil {
var originShielding OriginShieldingData
if err := s.r.Request(ctx, http.MethodPut, fmt.Sprintf("/cdn/resources/%d/shielding_v2", id), req, &originShielding); err != nil {
return nil, fmt.Errorf("request: %w", err)
}
return &origin_shielding, nil
return &originShielding, nil
}

func (s *Service) Get(ctx context.Context, id int64) (*OriginShieldingData, error) {
var origin_shielding OriginShieldingData
if err := s.r.Request(ctx, http.MethodGet, fmt.Sprintf("/cdn/resources/%d/shielding_v2", id), nil, &origin_shielding); err != nil {
var originShielding OriginShieldingData
if err := s.r.Request(ctx, http.MethodGet, fmt.Sprintf("/cdn/resources/%d/shielding_v2", id), nil, &originShielding); err != nil {
return nil, fmt.Errorf("request: %w", err)
}

return &origin_shielding, nil
return &originShielding, nil

}

func (s *Service) GetLocations(ctx context.Context) (*OriginShieldingLocations, error) {
var origin_shielding_locations OriginShieldingLocations
if err := s.r.Request(ctx, http.MethodGet, "/cdn/shieldingpop_v2", nil, &origin_shielding_locations); err != nil {
func (s *Service) GetLocations(ctx context.Context) ([]OriginShieldingLocations, error) {
var originShieldingLocations []OriginShieldingLocations
if err := s.r.Request(ctx, http.MethodGet, "/cdn/shieldingpop_v2", nil, originShieldingLocations); err != nil {
return nil, fmt.Errorf("request: %w", err)
}

return &origin_shielding_locations, nil
return originShieldingLocations, nil
}

0 comments on commit 0b2a40f

Please sign in to comment.