Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get rid of getstarted.html mentions #1442

Merged
merged 1 commit into from
Jul 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions backend/app/rest/api/rest.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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{
Expand Down
13 changes: 0 additions & 13 deletions backend/app/rest/api/rest_public.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import (
"fmt"
"io"
"net/http"
"os"
"path"
"strconv"
"strings"
"time"
Expand All @@ -32,7 +30,6 @@ type public struct {
readOnlyAge int
commentFormatter *store.CommentFormatter
imageService *image.Service
webRoot string
}

type pubStore interface {
Expand Down Expand Up @@ -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",
Expand Down
17 changes: 0 additions & 17 deletions backend/app/rest/api/rest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down