initial webapp

This commit is contained in:
natercio committed 2026-09-28 21:46:54 +01:00
1 parent 6c989c338c
commit d32f2b3a66
18 files changed
+1145 -16

No files matched your search

+33
View File
@@ -0,0 +1,33 @@
package web
import "sync"
// State holds the last rendered report table and row count produced by the
// upload handler. The web app is single-user and in-memory, but net/http runs
// handlers concurrently, so reads and writes are guarded by an RWMutex.
type State struct {
mu sync.RWMutex
table string
rows int
}
// NewState returns an empty State with no rendered table.
func NewState() *State {
return &State{}
}
// Set replaces the stored rendered table string and row count.
func (s *State) Set(table string, rows int) {
s.mu.Lock()
defer s.mu.Unlock()
s.table = table
s.rows = rows
}
// Get returns the current rendered table string and row count. The returned
// values are zero-valued when no upload has happened yet.
func (s *State) Get() (string, int) {
s.mu.RLock()
defer s.mu.RUnlock()
return s.table, s.rows
}