Skip to content

Commit d346d3c

Browse files
committed
all: remove some dead code
go/.export doesn't include click data anymore since we switched over to sqlite. Remove that code as well as the Link.Clicks field. Remove old /_/export redirect, since we've long since moved off of using it.
1 parent 555d133 commit d346d3c

File tree

2 files changed

+2
-13
lines changed

2 files changed

+2
-13
lines changed

db.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ type Link struct {
2424
Created time.Time
2525
LastEdit time.Time // when the link was last edited
2626
Owner string // user@domain
27-
Clicks int `json:",omitempty"` // number of times this link has been served
2827
}
2928

3029
// ClickStats is the number of clicks a set of links have received in a given

golink.go

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import (
2323
"path/filepath"
2424
"regexp"
2525
"sort"
26-
"strconv"
2726
"strings"
2827
"sync"
2928
texttemplate "text/template"
@@ -106,7 +105,6 @@ func Run() error {
106105
http.HandleFunc("/.detail/", serveDetail)
107106
http.HandleFunc("/.export", serveExport)
108107
http.HandleFunc("/.help", serveHelp)
109-
http.Handle("/_/export", http.RedirectHandler("/.export", http.StatusMovedPermanently))
110108
http.Handle("/.static/", http.StripPrefix("/.", http.FileServer(http.FS(embeddedFS))))
111109

112110
if *dev != "" {
@@ -237,7 +235,7 @@ func serveHome(w http.ResponseWriter, short string) {
237235
})
238236
}
239237

240-
func serveHelp(w http.ResponseWriter, r *http.Request) {
238+
func serveHelp(w http.ResponseWriter, _ *http.Request) {
241239
helpTmpl.Execute(w, nil)
242240
}
243241

@@ -507,17 +505,12 @@ func serveSave(w http.ResponseWriter, r *http.Request) {
507505
// serveExport prints a snapshot of the link database. Links are JSON encoded
508506
// and printed one per line. This format is used to restore link snapshots on
509507
// startup.
510-
func serveExport(w http.ResponseWriter, r *http.Request) {
508+
func serveExport(w http.ResponseWriter, _ *http.Request) {
511509
if err := flushStats(); err != nil {
512510
http.Error(w, err.Error(), http.StatusInternalServerError)
513511
return
514512
}
515513

516-
includeClicks := true
517-
if v := r.FormValue("clicks"); v != "" {
518-
includeClicks, _ = strconv.ParseBool(v)
519-
}
520-
521514
links, err := db.LoadAll()
522515
if err != nil {
523516
http.Error(w, err.Error(), http.StatusInternalServerError)
@@ -528,9 +521,6 @@ func serveExport(w http.ResponseWriter, r *http.Request) {
528521
})
529522
encoder := json.NewEncoder(w)
530523
for _, link := range links {
531-
if !includeClicks {
532-
link.Clicks = 0
533-
}
534524
if err := encoder.Encode(link); err != nil {
535525
panic(http.ErrAbortHandler)
536526
}

0 commit comments

Comments
 (0)