Skip to content

Commit

Permalink
added a cache buster to all endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
Joel Hill committed Jul 20, 2018
1 parent 70016ae commit 8f6be23
Show file tree
Hide file tree
Showing 20 changed files with 98 additions and 23 deletions.
6 changes: 5 additions & 1 deletion current_season.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"errors"
"fmt"
"time"

blaster "github.com/joelhill/go-rest-http-blaster"
logrus "github.com/sirupsen/logrus"
Expand Down Expand Up @@ -43,7 +44,10 @@ func (s *Service) CurrentSeason(c context.Context, options *CurrentSeasonOptions
return mapping, err
}

uri := fmt.Sprintf("%s/%s/pull/%s/current_season.%s?1=1", options.URL, options.Version, options.Sport, options.Format)
t := time.Now()
cacheBuster := t.Format("20060102150405")

uri := fmt.Sprintf("%s/%s/pull/%s/current_season.%s?cachebuster=%s", options.URL, options.Version, options.Sport, options.Format, cacheBuster)

if len(options.Date) > 0 {
uri = fmt.Sprintf("%s&date=%s", uri, options.Date)
Expand Down
6 changes: 5 additions & 1 deletion daily_dfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"errors"
"fmt"
"time"

blaster "github.com/joelhill/go-rest-http-blaster"
logrus "github.com/sirupsen/logrus"
Expand Down Expand Up @@ -53,7 +54,10 @@ func (s *Service) DailyDfs(c context.Context, options *DailyDfsOptions) (DfsIO,
return mapping, err
}

uri := fmt.Sprintf("%s/%s/pull/%s/%s/date/%s/dfs.%s?1=1", options.URL, options.Version, options.Sport, options.Season, options.Date, options.Format)
t := time.Now()
cacheBuster := t.Format("20060102150405")

uri := fmt.Sprintf("%s/%s/pull/%s/%s/date/%s/dfs.%s?cachebuster=%s", options.URL, options.Version, options.Sport, options.Season, options.Date, options.Format, cacheBuster)

if len(options.Team) > 0 {
uri = fmt.Sprintf("%s&team=%s", uri, options.Team)
Expand Down
6 changes: 5 additions & 1 deletion daily_games.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"errors"
"fmt"
"time"

blaster "github.com/joelhill/go-rest-http-blaster"
logrus "github.com/sirupsen/logrus"
Expand Down Expand Up @@ -50,7 +51,10 @@ func (s *Service) DailyGames(c context.Context, options *DailyGamesOptions) (Gam
return mapping, err
}

uri := fmt.Sprintf("%s/%s/pull/%s/%s/date/%s/games.%s?1=1", options.URL, options.Version, options.Sport, options.Season, options.Date, options.Format)
t := time.Now()
cacheBuster := t.Format("20060102150405")

uri := fmt.Sprintf("%s/%s/pull/%s/%s/date/%s/games.%s?cachebuster=%s", options.URL, options.Version, options.Sport, options.Season, options.Date, options.Format, cacheBuster)

if len(options.Team) > 0 {
uri = fmt.Sprintf("%s&team=%s", uri, options.Team)
Expand Down
6 changes: 5 additions & 1 deletion daily_player_gamelogs.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"errors"
"fmt"
"time"

blaster "github.com/joelhill/go-rest-http-blaster"
logrus "github.com/sirupsen/logrus"
Expand Down Expand Up @@ -54,7 +55,10 @@ func (s *Service) DailyPlayerGamelogs(c context.Context, options *DailyPlayerGam
return mapping, err
}

uri := fmt.Sprintf("%s/%s/pull/%s/%s/date/%s/week/%s/player_gamelogs.%s?1=1", options.URL, options.Version, options.Sport, options.Season, options.Date, options.Week, options.Format)
t := time.Now()
cacheBuster := t.Format("20060102150405")

uri := fmt.Sprintf("%s/%s/pull/%s/%s/date/%s/week/%s/player_gamelogs.%s?cachebuster=%s", options.URL, options.Version, options.Sport, options.Season, options.Date, options.Week, options.Format, cacheBuster)

if len(options.Team) > 0 {
uri = fmt.Sprintf("%s&team=%s", uri, options.Team)
Expand Down
6 changes: 5 additions & 1 deletion daily_standings.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"errors"
"fmt"
"time"

blaster "github.com/joelhill/go-rest-http-blaster"
logrus "github.com/sirupsen/logrus"
Expand Down Expand Up @@ -47,7 +48,10 @@ func (s *Service) DailyStandings(c context.Context, options *DailyStandingsOptio
return mapping, err
}

uri := fmt.Sprintf("%s/%s/pull/%s/%s/standings.%s?1=1", options.URL, options.Version, options.Sport, options.Season, options.Format)
t := time.Now()
cacheBuster := t.Format("20060102150405")

uri := fmt.Sprintf("%s/%s/pull/%s/%s/standings.%s?cachebuster=%s", options.URL, options.Version, options.Sport, options.Season, options.Format, cacheBuster)

if len(options.Date) > 0 {
uri = fmt.Sprintf("%s&date=%s", uri, options.Date)
Expand Down
6 changes: 5 additions & 1 deletion daily_team_gamelogs.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"errors"
"fmt"
"time"

blaster "github.com/joelhill/go-rest-http-blaster"
logrus "github.com/sirupsen/logrus"
Expand Down Expand Up @@ -51,7 +52,10 @@ func (s *Service) DailyTeamGamelogs(c context.Context, options *DailyTeamGamelog
return mapping, err
}

uri := fmt.Sprintf("%s/%s/pull/%s/%s/date/%s/team_gamelogs.%s?1=1", options.URL, options.Version, options.Sport, options.Season, options.Date, options.Format)
t := time.Now()
cacheBuster := t.Format("20060102150405")

uri := fmt.Sprintf("%s/%s/pull/%s/%s/date/%s/team_gamelogs.%s?cachebuster=%s", options.URL, options.Version, options.Sport, options.Season, options.Date, options.Format, cacheBuster)

if len(options.Team) > 0 {
uri = fmt.Sprintf("%s&team=%s", uri, options.Team)
Expand Down
7 changes: 3 additions & 4 deletions examples/example.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,12 @@ import (
)

func main() {
config := sf.NewConfig("Basic setthishere")
config := sf.NewConfig("Basic amlnZ2lkeXVvOk1ZU1BPUlRTRkVFRFM=")

client := sf.NewService(config)
c := context.Background()
dailyGameOptions := client.NewDailyGamesOptions()
dailyGameOptions.Date = "20180715"
sg, sgErr := client.DailyGames(c, dailyGameOptions)
dailyGameOptions := client.NewCurrentSeasonOptions()
sg, sgErr := client.CurrentSeason(c, dailyGameOptions)

spew.Dump(sg)
spew.Dump(sgErr)
Expand Down
6 changes: 5 additions & 1 deletion feed_updates.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"errors"
"fmt"
"time"

blaster "github.com/joelhill/go-rest-http-blaster"
logrus "github.com/sirupsen/logrus"
Expand Down Expand Up @@ -44,7 +45,10 @@ func (s *Service) FeedUpdates(c context.Context, options *FeedUpdatesOptions) (F
return mapping, err
}

uri := fmt.Sprintf("%s/%s/pull/%s/latest_updates.%s?1=1", options.URL, options.Version, options.Sport, options.Format)
t := time.Now()
cacheBuster := t.Format("20060102150405")

uri := fmt.Sprintf("%s/%s/pull/%s/latest_updates.%s?cachebuster=%s", options.URL, options.Version, options.Sport, options.Format, cacheBuster)

if len(options.Force) > 0 {
uri = fmt.Sprintf("%s&force=%s", uri, options.Force)
Expand Down
6 changes: 5 additions & 1 deletion game_boxscore.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"errors"
"fmt"
"time"

blaster "github.com/joelhill/go-rest-http-blaster"
logrus "github.com/sirupsen/logrus"
Expand Down Expand Up @@ -50,7 +51,10 @@ func (s *Service) GameBoxscore(c context.Context, options *GameBoxscoreOptions)
return mapping, err
}

uri := fmt.Sprintf("%s/%s/pull/%s/%s/games/%s/boxscore.%s?1=1", options.URL, options.Version, options.Sport, options.Season, options.Game, options.Format)
t := time.Now()
cacheBuster := t.Format("20060102150405")

uri := fmt.Sprintf("%s/%s/pull/%s/%s/games/%s/boxscore.%s?cachebuster=%s", options.URL, options.Version, options.Sport, options.Season, options.Game, options.Format, cacheBuster)

if len(options.TeamStats) > 0 {
uri = fmt.Sprintf("%s&teamstats=%s", uri, options.TeamStats)
Expand Down
6 changes: 5 additions & 1 deletion game_lineup.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"errors"
"fmt"
"time"

blaster "github.com/joelhill/go-rest-http-blaster"
logrus "github.com/sirupsen/logrus"
Expand Down Expand Up @@ -47,7 +48,10 @@ func (s *Service) GameLineup(c context.Context, options *GameLineupOptions) (Gam
return mapping, err
}

uri := fmt.Sprintf("%s/%s/pull/%s/%s/games/%s/lineup.%s?1=1", options.URL, options.Version, options.Sport, options.Season, options.Game, options.Format)
t := time.Now()
cacheBuster := t.Format("20060102150405")

uri := fmt.Sprintf("%s/%s/pull/%s/%s/games/%s/lineup.%s?cachebuster=%s", options.URL, options.Version, options.Sport, options.Season, options.Game, options.Format, cacheBuster)

if len(options.Position) > 0 {
uri = fmt.Sprintf("%s&position=%s", uri, options.Position)
Expand Down
6 changes: 5 additions & 1 deletion game_play_by_play.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"errors"
"fmt"
"time"

blaster "github.com/joelhill/go-rest-http-blaster"
logrus "github.com/sirupsen/logrus"
Expand Down Expand Up @@ -49,7 +50,10 @@ func (s *Service) GamePlayByPlay(c context.Context, options *GamePlayByPlayOptio
return mapping, err
}

uri := fmt.Sprintf("%s/%s/pull/%s/%s/games/%s/playbyplay.%s?1=1", options.URL, options.Version, options.Sport, options.Season, options.Game, options.Format)
t := time.Now()
cacheBuster := t.Format("20060102150405")

uri := fmt.Sprintf("%s/%s/pull/%s/%s/games/%s/playbyplay.%s?cachebuster=%s", options.URL, options.Version, options.Sport, options.Season, options.Game, options.Format, cacheBuster)

if len(options.Playtype) > 0 {
uri = fmt.Sprintf("%s&playtype=%s", uri, options.Playtype)
Expand Down
6 changes: 5 additions & 1 deletion player_injuries.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"errors"
"fmt"
"time"

blaster "github.com/joelhill/go-rest-http-blaster"
logrus "github.com/sirupsen/logrus"
Expand Down Expand Up @@ -48,7 +49,10 @@ func (s *Service) PlayerInjuries(c context.Context, options *PlayerInjuriesOptio
return mapping, err
}

uri := fmt.Sprintf("%s/%s/pull/%s/current_season.%s?1=1", options.URL, options.Version, options.Sport, options.Format)
t := time.Now()
cacheBuster := t.Format("20060102150405")

uri := fmt.Sprintf("%s/%s/pull/%s/current_season.%s?cachebuster=%s", options.URL, options.Version, options.Sport, options.Format, cacheBuster)

if len(options.Player) > 0 {
uri = fmt.Sprintf("%s&player=%s", uri, options.Player)
Expand Down
6 changes: 5 additions & 1 deletion players.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"errors"
"fmt"
"time"

blaster "github.com/joelhill/go-rest-http-blaster"
logrus "github.com/sirupsen/logrus"
Expand Down Expand Up @@ -51,7 +52,10 @@ func (s *Service) Players(c context.Context, options *PlayersOptions) (PlayersIO
return mapping, err
}

uri := fmt.Sprintf("%s/%s/pull/%s/players.%s?1=1", options.URL, options.Version, options.Sport, options.Format)
t := time.Now()
cacheBuster := t.Format("20060102150405")

uri := fmt.Sprintf("%s/%s/pull/%s/players.%s?cachebuster=%s", options.URL, options.Version, options.Sport, options.Format, cacheBuster)

if len(options.Date) > 0 {
uri = fmt.Sprintf("%s&date=%s", uri, options.Date)
Expand Down
6 changes: 5 additions & 1 deletion seasonal_dfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"errors"
"fmt"
"time"

blaster "github.com/joelhill/go-rest-http-blaster"
logrus "github.com/sirupsen/logrus"
Expand Down Expand Up @@ -52,7 +53,10 @@ func (s *Service) SeasonalDfs(c context.Context, options *SeasonalDfsOptions) (D
return mapping, err
}

uri := fmt.Sprintf("%s/%s/pull/%s/%s/dfs.%s?1=1", options.URL, options.Version, options.Sport, options.Season, options.Format)
t := time.Now()
cacheBuster := t.Format("20060102150405")

uri := fmt.Sprintf("%s/%s/pull/%s/%s/dfs.%s?cachebuster=%s", options.URL, options.Version, options.Sport, options.Season, options.Format, cacheBuster)

if len(options.Team) > 0 {
uri = fmt.Sprintf("%s&team=%s", uri, options.Team)
Expand Down
6 changes: 5 additions & 1 deletion seasonal_games.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"errors"
"fmt"
"time"

blaster "github.com/joelhill/go-rest-http-blaster"
logrus "github.com/sirupsen/logrus"
Expand Down Expand Up @@ -50,7 +51,10 @@ func (s *Service) SeasonalGames(c context.Context, options *SeasonalGamesOptions
return mapping, err
}

uri := fmt.Sprintf("%s/%s/pull/%s/%s/games.%s?1=1", options.URL, options.Version, options.Sport, options.Season, options.Format)
t := time.Now()
cacheBuster := t.Format("20060102150405")

uri := fmt.Sprintf("%s/%s/pull/%s/%s/games.%s?cachebuster=%s", options.URL, options.Version, options.Sport, options.Season, options.Format, cacheBuster)

if len(options.Team) > 0 {
uri = fmt.Sprintf("%s&team=%s", uri, options.Team)
Expand Down
6 changes: 5 additions & 1 deletion seasonal_player_gamelogs.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"errors"
"fmt"
"time"

blaster "github.com/joelhill/go-rest-http-blaster"
logrus "github.com/sirupsen/logrus"
Expand Down Expand Up @@ -53,7 +54,10 @@ func (s *Service) SeasonalPlayerGamelogs(c context.Context, options *SeasonalPla
return mapping, err
}

uri := fmt.Sprintf("%s/%s/pull/%s/%s/player_gamelogs.%s?1=1", options.URL, options.Version, options.Sport, options.Season, options.Format)
t := time.Now()
cacheBuster := t.Format("20060102150405")

uri := fmt.Sprintf("%s/%s/pull/%s/%s/player_gamelogs.%s?cachebuster=%s", options.URL, options.Version, options.Sport, options.Season, options.Format, cacheBuster)

if len(options.Team) > 0 {
uri = fmt.Sprintf("%s&team=%s", uri, options.Team)
Expand Down
6 changes: 5 additions & 1 deletion seasonal_player_stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"errors"
"fmt"
"time"

blaster "github.com/joelhill/go-rest-http-blaster"
logrus "github.com/sirupsen/logrus"
Expand Down Expand Up @@ -53,7 +54,10 @@ func (s *Service) SeasonalPlayerStats(c context.Context, options *SeasonalPlayer
return mapping, err
}

uri := fmt.Sprintf("%s/%s/pull/%s/%s/player_stats_totals.%s?1=1", options.URL, options.Version, options.Sport, options.Season, options.Format)
t := time.Now()
cacheBuster := t.Format("20060102150405")

uri := fmt.Sprintf("%s/%s/pull/%s/%s/player_stats_totals.%s?cachebuster=%s", options.URL, options.Version, options.Sport, options.Season, options.Format, cacheBuster)

if len(options.Player) > 0 {
uri = fmt.Sprintf("%s&player=%s", uri, options.Player)
Expand Down
6 changes: 5 additions & 1 deletion seasonal_team_gamelogs.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"errors"
"fmt"
"time"

blaster "github.com/joelhill/go-rest-http-blaster"
logrus "github.com/sirupsen/logrus"
Expand Down Expand Up @@ -51,7 +52,10 @@ func (s *Service) SeasonalTeamGamelogs(c context.Context, options *SeasonalTeamG
return mapping, err
}

uri := fmt.Sprintf("%s/%s/pull/%s/%s/team_gamelogs.%s?1=1", options.URL, options.Version, options.Sport, options.Season, options.Format)
t := time.Now()
cacheBuster := t.Format("20060102150405")

uri := fmt.Sprintf("%s/%s/pull/%s/%s/team_gamelogs.%s?cachebuster=%s", options.URL, options.Version, options.Sport, options.Season, options.Format, cacheBuster)

if len(options.Team) > 0 {
uri = fmt.Sprintf("%s&team=%s", uri, options.Team)
Expand Down
6 changes: 5 additions & 1 deletion seasonal_team_stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"errors"
"fmt"
"time"

blaster "github.com/joelhill/go-rest-http-blaster"
logrus "github.com/sirupsen/logrus"
Expand Down Expand Up @@ -50,7 +51,10 @@ func (s *Service) SeasonalTeamStats(c context.Context, options *SeasonalTeamStat
return mapping, err
}

uri := fmt.Sprintf("%s/%s/pull/%s/%s/team_stats_totals.%s?1=1", options.URL, options.Version, options.Sport, options.Season, options.Format)
t := time.Now()
cacheBuster := t.Format("20060102150405")

uri := fmt.Sprintf("%s/%s/pull/%s/%s/team_stats_totals.%s?cachebuster=%s", options.URL, options.Version, options.Sport, options.Season, options.Format, cacheBuster)

if len(options.Team) > 0 {
uri = fmt.Sprintf("%s&team=%s", uri, options.Team)
Expand Down
6 changes: 5 additions & 1 deletion seasonal_venues.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"errors"
"fmt"
"time"

blaster "github.com/joelhill/go-rest-http-blaster"
logrus "github.com/sirupsen/logrus"
Expand Down Expand Up @@ -45,7 +46,10 @@ func (s *Service) SeasonalVenues(c context.Context, options *SeasonalVenuesOptio
return mapping, err
}

uri := fmt.Sprintf("%s/%s/pull/%s/%s/venues.%s?1=1", options.URL, options.Version, options.Sport, options.Season, options.Format)
t := time.Now()
cacheBuster := t.Format("20060102150405")

uri := fmt.Sprintf("%s/%s/pull/%s/%s/venues.%s?cachebuster=%s", options.URL, options.Version, options.Sport, options.Season, options.Format, cacheBuster)

if len(options.Team) > 0 {
uri = fmt.Sprintf("%s&team=%s", uri, options.Team)
Expand Down

0 comments on commit 8f6be23

Please sign in to comment.