all repos — homestead @ bab78381a9c54b809dc76144aa9f773d387bb621

Code for my website

rename countkey to title

Alan Pearce
commit

bab78381a9c54b809dc76144aa9f773d387bb621

parent

7cc6162387db91d5be21121d8c6d232f06b513ad

2 files changed, 10 insertions(+), 10 deletions(-)

changed files
M domain/analytics/middleware.godomain/analytics/middleware.go
@@ -9,14 +9,14 @@ )
type contextKey struct{} -var countKeyContextKey contextKey +var titleContextKey contextKey -func WithCountKey(r *http.Request, key string) *http.Request { - return r.WithContext(context.WithValue(r.Context(), countKeyContextKey, key)) +func WithTitle(r *http.Request, key string) *http.Request { + return r.WithContext(context.WithValue(r.Context(), titleContextKey, key)) } -func GetCountKey(r *http.Request) (string, bool) { - key, ok := r.Context().Value(countKeyContextKey).(string) +func GetTitle(r *http.Request) (string, bool) { + key, ok := r.Context().Value(titleContextKey).(string) return key, ok }
@@ -28,15 +28,15 @@ rw := sharedhttp.NewStatusCapturingResponseWriter(w)
next.ServeHTTP(rw, r) - countKey, ok := GetCountKey(r) + title, ok := GetTitle(r) if !ok { if rw.Status >= 201 { - countKey = http.StatusText(rw.Status) + title = http.StatusText(rw.Status) } } if rw.Status <= 299 { - counter.Count(r, countKey) + counter.Count(r, title) } }) }
M domain/web/mux.godomain/web/mux.go
@@ -48,7 +48,7 @@ }
if file == nil { return ihttp.NotFound("File not found") } - analytics.WithCountKey(r, file.Title) + analytics.WithTitle(r, file.Title) w.Header().Add("ETag", file.Etag) w.Header().Add("Vary", "Accept-Encoding") if file.StyleHash != "" {
@@ -74,7 +74,7 @@ return nil
} func (website *Website) Calendar(w http.ResponseWriter, r *http.Request) ihttp.Error { - analytics.WithCountKey(r, "Calendar") + analytics.WithTitle(r, "Calendar") err := calendar.CalendarPage(*website.siteSettings, website.calendar).Render(w) if err != nil { return ihttp.InternalServerError("could not render calendar page", err)