From 63a2bdea48b78ed53a7e8f6ea5ef82414b37940c Mon Sep 17 00:00:00 2001 From: Dmitry Verkhoturov Date: Wed, 27 Jul 2022 02:21:20 +0200 Subject: [PATCH] get rid of getstarted.html mentions umputun introduced that reference in 70649b271, but I can't find any references to it or the file itself now. --- backend/app/rest/api/rest.go | 2 -- backend/app/rest/api/rest_public.go | 13 ------------- backend/app/rest/api/rest_test.go | 17 ----------------- 3 files changed, 32 deletions(-) diff --git a/backend/app/rest/api/rest.go b/backend/app/rest/api/rest.go index 9e2db6ff..bb651482 100644 --- a/backend/app/rest/api/rest.go +++ b/backend/app/rest/api/rest.go @@ -347,7 +347,6 @@ func (s *Rest) routes() chi.Router { router.Group(func(rroot chi.Router) { rroot.Use(middleware.Timeout(10 * time.Second)) rroot.Use(tollbooth_chi.LimitHandler(tollbooth.NewLimiter(50, nil))) - rroot.Get("/index.html", s.pubRest.getStartedCtrl) rroot.Get("/robots.txt", s.pubRest.robotsCtrl) rroot.Get("/email/unsubscribe.html", s.privRest.emailUnsubscribeCtrl) rroot.Post("/email/unsubscribe.html", s.privRest.emailUnsubscribeCtrl) @@ -365,7 +364,6 @@ func (s *Rest) controllerGroups() (public, private, admin, rss) { imageService: s.ImageService, commentFormatter: s.CommentFormatter, readOnlyAge: s.ReadOnlyAge, - webRoot: s.WebRoot, } privGrp := private{ diff --git a/backend/app/rest/api/rest_public.go b/backend/app/rest/api/rest_public.go index 5ebd704d..b6f5dbac 100644 --- a/backend/app/rest/api/rest_public.go +++ b/backend/app/rest/api/rest_public.go @@ -7,8 +7,6 @@ import ( "fmt" "io" "net/http" - "os" - "path" "strconv" "strings" "time" @@ -32,7 +30,6 @@ type public struct { readOnlyAge int commentFormatter *store.CommentFormatter imageService *image.Service - webRoot string } type pubStore interface { @@ -345,16 +342,6 @@ func (s *public) loadPictureCtrl(w http.ResponseWriter, r *http.Request) { } } -// GET /index.html - respond to /index.html with the content of getstarted.html under /web root -func (s *public) getStartedCtrl(w http.ResponseWriter, r *http.Request) { - data, err := os.ReadFile(path.Join(s.webRoot, "getstarted.html")) - if err != nil { - w.WriteHeader(http.StatusNotFound) - return - } - render.HTML(w, r, string(data)) -} - // GET /robots.txt func (s *public) robotsCtrl(w http.ResponseWriter, r *http.Request) { allowed := []string{"/find", "/last", "/id", "/count", "/counts", "/list", "/config", "/user", diff --git a/backend/app/rest/api/rest_test.go b/backend/app/rest/api/rest_test.go index 1700074b..38cc777d 100644 --- a/backend/app/rest/api/rest_test.go +++ b/backend/app/rest/api/rest_test.go @@ -60,23 +60,6 @@ func TestRest_FileServer(t *testing.T) { _ = os.Remove(testHTMLFile) } -func TestRest_GetStarted(t *testing.T) { - ts, _, teardown := startupT(t) - defer teardown() - - getStartedHTML := os.TempDir() + "/getstarted.html" - err := os.WriteFile(getStartedHTML, []byte("some html blah"), 0o700) - assert.NoError(t, err) - - body, code := get(t, ts.URL+"/index.html") - assert.Equal(t, http.StatusOK, code) - assert.Equal(t, "some html blah", body) - - _ = os.Remove(getStartedHTML) - _, code = get(t, ts.URL+"/index.html") - assert.Equal(t, http.StatusNotFound, code) -} - func TestRest_Shutdown(t *testing.T) { srv := Rest{Authenticator: &auth.Service{}, ImageProxy: &proxy.Image{}} done := make(chan bool)