summaryrefslogtreecommitdiffhomepage
path: root/main.go
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2024-08-11 22:33:34 +0200
committerThomas Voss <mail@thomasvoss.com> 2024-08-11 22:33:34 +0200
commit574fd098228f5b63d10a4a739ee7b8e6c668a671 (patch)
tree171ec68e046af60af0861ac42eeb6dc54138f7e7 /main.go
parenta0c502e3a1490e5b69bb550f2fb4f79fadfa34b7 (diff)
More work on mintages
Diffstat (limited to 'main.go')
-rw-r--r--main.go16
1 files changed, 14 insertions, 2 deletions
diff --git a/main.go b/main.go
index 21a3b1a..270eabb 100644
--- a/main.go
+++ b/main.go
@@ -111,15 +111,27 @@ func mintageHandler(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
countries := lib.SortedCountries(
r.Context().Value("printer").(lib.Printer))
- code := cmp.Or(r.FormValue("c"), countries[0].Code)
+ code := strings.ToLower(cmp.Or(r.FormValue("code"), countries[0].Code))
+ ctype := strings.ToLower(cmp.Or(r.FormValue("type"), "circ"))
path := filepath.Join("data", "mintages", code)
f, _ := os.Open(path) // TODO: Handle error
defer f.Close()
set, _ := mintage.Parse(f, path) // TODO: Handle error
+ var idx mintage.CoinType
+ switch ctype {
+ case "circ":
+ idx = mintage.TypeCirculated
+ case "nifc":
+ idx = mintage.TypeNIFC
+ case "proof":
+ idx = mintage.TypeProof
+ }
+
ctx := context.WithValue(r.Context(), "code", code)
- ctx = context.WithValue(ctx, "set", set)
+ ctx = context.WithValue(ctx, "type", ctype)
+ ctx = context.WithValue(ctx, "table", set.Tables[idx])
ctx = context.WithValue(ctx, "countries", countries)
next.ServeHTTP(w, r.WithContext(ctx))
})