add rate limiting, CSRF, newsletter, auto-checker, /uses and /projects pages

This commit is contained in:
Blake Ridgway
2026-03-11 14:12:52 -05:00
parent 261745a5b7
commit 58831e2429
17 changed files with 913 additions and 19 deletions

View File

@@ -4,15 +4,19 @@ package status
import (
"encoding/json"
"os"
"sync"
"time"
)
var mu sync.RWMutex
// Service represents a single monitored service.
type Service struct {
Name string `json:"name"`
Description string `json:"description"`
URL string `json:"url,omitempty"`
Status string `json:"status"` // "up", "degraded", "down", "unknown"
CheckURL string `json:"check_url,omitempty"` // HTTP URL probed automatically; empty = manual
Status string `json:"status"` // "up", "degraded", "down", "unknown"
Note string `json:"note,omitempty"`
}
@@ -24,6 +28,12 @@ type Page struct {
// Load reads and parses the status JSON from path.
func Load(path string) (*Page, error) {
mu.RLock()
defer mu.RUnlock()
return load(path)
}
func load(path string) (*Page, error) {
raw, err := os.ReadFile(path)
if err != nil {
return nil, err
@@ -37,6 +47,8 @@ func Load(path string) (*Page, error) {
// Save writes the status page data back to path.
func Save(path string, p *Page) error {
mu.Lock()
defer mu.Unlock()
p.LastChecked = time.Now().UTC()
raw, err := json.MarshalIndent(p, "", " ")
if err != nil {