Skip to content

Commit

Permalink
Support deprecated URLs for future us's to deal with.
Browse files Browse the repository at this point in the history
  • Loading branch information
bvanvugt committed Dec 6, 2023
1 parent f777a8b commit eef5dd8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
8 changes: 8 additions & 0 deletions http/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,10 @@ func handleGIFFrameDimensions(w http.ResponseWriter, r *http.Request) {
handleGIFFrameCommon(w, r, width, height)
}

func handleGIFFrame(w http.ResponseWriter, r *http.Request) {
handleGIFFrameCommon(w, r, 0, 0)
}

func handleGIFFrameCommon(w http.ResponseWriter, r *http.Request, width, height int) {
gameID := pat.Param(r, "game")
frameID, err := strconv.Atoi(pat.Param(r, "frame"))
Expand Down Expand Up @@ -345,6 +349,10 @@ func handleGIFGameDimensions(w http.ResponseWriter, r *http.Request) {
handleCommonGIFGame(w, r, width, height)
}

func handleGIFGame(w http.ResponseWriter, r *http.Request) {
handleCommonGIFGame(w, r, 0, 0)
}

func handleCommonGIFGame(w http.ResponseWriter, r *http.Request, width, height int) {

gameID := pat.Param(r, "game")
Expand Down
5 changes: 5 additions & 0 deletions http/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ func NewServer() *Server {
mux.HandleFunc(pat.Get("/games/:game/frames/:frame.txt"), withCaching(handleASCIIFrame))
mux.HandleFunc(pat.Get("/games/:game/frames/:frame/:size.gif"), withCaching(handleGIFFrameDimensions))

// Deprecated and undocumented, remove these!
mux.HandleFunc(pat.Get("/games/:game/gif"), withCaching(handleGIFGame))
mux.HandleFunc(pat.Get("/games/:game/frames/:frame/ascii"), withCaching(handleASCIIFrame))
mux.HandleFunc(pat.Get("/games/:game/frames/:frame/gif"), withCaching(handleGIFFrame))

return &Server{
router: mux,
httpServer: &http.Server{
Expand Down

0 comments on commit eef5dd8

Please sign in to comment.