Add credential-free sample mode with sample data, README, and doc reconciliation

This commit is contained in:
Ian Gulliver
2026-08-16 13:14:30 -07:00
parent 2b6e77c766
commit 8c9c1a6cd6
12 changed files with 166 additions and 75 deletions
+6
View File
@@ -39,6 +39,12 @@ func Email(r *http.Request) string {
return email
}
func Fixed(email string, next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
next.ServeHTTP(w, r.WithContext(context.WithValue(r.Context(), contextKey{}, email)))
})
}
func (a *Auth) Register(mux *http.ServeMux) {
mux.HandleFunc("POST /auth/login", a.login)
mux.HandleFunc("POST /auth/logout", a.logout)
+6 -2
View File
@@ -11,15 +11,19 @@ import (
const refreshInterval = 5 * time.Minute
type Geocoder interface {
Lookup(address string) (geocode.Point, error)
}
type Cache struct {
source data.Source
geocoder *geocode.Client
geocoder Geocoder
blobs BlobChecker
mu sync.RWMutex
model *Model
}
func NewCache(source data.Source, geocoder *geocode.Client, blobs BlobChecker) (*Cache, error) {
func NewCache(source data.Source, geocoder Geocoder, blobs BlobChecker) (*Cache, error) {
c := &Cache{source: source, geocoder: geocoder, blobs: blobs}
if err := c.refresh(); err != nil {
return nil, err
+13
View File
@@ -0,0 +1,13 @@
package geocode
import "crypto/sha256"
type Fake struct{}
func (Fake) Lookup(address string) (Point, error) {
sum := sha256.Sum256([]byte(address))
return Point{
Lat: 37.5 + (float64(sum[0])/255-0.5)*0.12,
Lng: -122.45 + (float64(sum[1])/255-0.5)*0.12,
}, nil
}