package main import ( "net/http" "strconv" "strings" "inou/lib" ) func handleContactSheet(w http.ResponseWriter, r *http.Request) { seriesHex := strings.TrimPrefix(r.URL.Path, "/contact-sheet.webp/") if seriesHex == "" || len(seriesHex) != 16 { http.Error(w, "Invalid series ID", http.StatusBadRequest) return } ctx := getAccessContextOrFail(w, r) if ctx == nil { return } q := r.URL.Query() var wc, ww float64 if v := q.Get("wc"); v != "" { wc, _ = strconv.ParseFloat(v, 64) } if v := q.Get("ww"); v != "" { ww, _ = strconv.ParseFloat(v, 64) } body, err := lib.RenderContactSheet(ctx.AccessorID, seriesHex, wc, ww) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return } w.Header().Set("Content-Type", "image/webp") w.Header().Set("Cache-Control", "public, max-age=3600") w.Write(body) }