From 3f644328732ea13563e33c962042adb6f70451e9 Mon Sep 17 00:00:00 2001 From: Denys Sedchenko Date: Sat, 14 Dec 2024 15:29:09 -0500 Subject: [PATCH] feat: remove deprecated endpoints (#454) --- internal/server/handler_v1.go | 57 ----------------------------------- 1 file changed, 57 deletions(-) diff --git a/internal/server/handler_v1.go b/internal/server/handler_v1.go index 3be78696..d0d5fad3 100644 --- a/internal/server/handler_v1.go +++ b/internal/server/handler_v1.go @@ -3,7 +3,6 @@ package server import ( "context" "errors" - "github.com/x1unix/go-playground/pkg/monaco" "io" "net/http" "strconv" @@ -26,8 +25,6 @@ const ( artifactParamVal = "artifactId" ) -var apiv1SunsetDate = time.Date(2024, time.October, 1, 0, 0, 0, 0, time.UTC) - type BackendVersionProvider interface { GetVersions(ctx context.Context) (*VersionsInformation, error) } @@ -67,10 +64,6 @@ func (s *APIv1Handler) Mount(r *mux.Router) { HandlerFunc(WrapHandler(s.HandleGetVersions)) r.Path("/artifacts/{artifactId:[a-fA-F0-9]+}.wasm").Methods(http.MethodGet). HandlerFunc(WrapHandler(s.HandleArtifactRequest)) - - // TODO: remove endpoint in the next release - r.Path("/suggest"). - HandlerFunc(WrapHandler(DeprecatedEndpoint(s.HandleGetSuggestion, apiv1SunsetDate))) } // HandleGetVersion handles /api/version @@ -79,56 +72,6 @@ func (s *APIv1Handler) HandleGetVersion(w http.ResponseWriter, _ *http.Request) return nil } -// HandleGetSuggestion handles code suggestion -func (s *APIv1Handler) HandleGetSuggestion(w http.ResponseWriter, r *http.Request) error { - resp := SuggestionsResponse{ - Suggestions: []monaco.CompletionItem{}, - } - resp.Write(w) - return nil -} - -// HandleShare handles snippet share -func (s *APIv1Handler) HandleShare(w http.ResponseWriter, r *http.Request) error { - shareID, err := s.client.Share(r.Context(), r.Body) - defer r.Body.Close() - if err != nil { - if isContentLengthError(err) { - return ErrSnippetTooLarge - } - - s.log.Error("failed to share code: ", err) - return err - } - - WriteJSON(w, ShareResponse{SnippetID: shareID}) - return nil -} - -// HandleGetSnippet handles snippet load -func (s *APIv1Handler) HandleGetSnippet(w http.ResponseWriter, r *http.Request) error { - vars := mux.Vars(r) - snippetID := vars["id"] - snippet, err := s.client.GetSnippet(r.Context(), snippetID) - if err != nil { - if errors.Is(err, goplay.ErrSnippetNotFound) { - return Errorf(http.StatusNotFound, "snippet %q not found", snippetID) - } - - s.log.Errorw("failed to get snippet", - "snippetID", snippetID, - "err", err, - ) - return err - } - - WriteJSON(w, SnippetResponse{ - FileName: snippet.FileName, - Code: snippet.Contents, - }) - return nil -} - func (s *APIv1Handler) HandleGetVersions(w http.ResponseWriter, r *http.Request) error { versions, err := s.versionProvider.GetVersions(r.Context()) if err != nil {