Files
paliad/internal/handlers/handlers.go
m 0960235bb8 feat: searchable DE/EN patent glossary with term suggestions
- New /glossar page with 73 bilingual patent law terms across 5 categories
  (Litigation, Prosecution, UPC, EPA, General)
- Client-side instant search filtering both DE and EN columns
- Category filter pills for quick narrowing
- Suggest-a-term button opens modal form for new term submissions
- Per-term feedback icon for correction suggestions
- Suggestions stored in Supabase (glossar_suggestions table with RLS)
- Go API: GET /api/glossar (terms JSON), POST /api/glossar/suggest
- Full DE/EN i18n support, responsive layout, print-friendly
- Added to sidebar nav, landing page tools section, and build pipeline
2026-04-14 20:06:51 +02:00

53 lines
1.8 KiB
Go

package handlers
import (
"encoding/json"
"net/http"
"mgit.msbls.de/m/patholo/internal/auth"
)
var authClient *auth.Client
func Register(mux *http.ServeMux, client *auth.Client, giteaAPIToken string) {
authClient = client
giteaToken = giteaAPIToken
// API endpoints (JSON, public)
mux.HandleFunc("POST /api/login", handleAPILogin)
mux.HandleFunc("POST /api/register", handleAPIRegister)
// Public pages
mux.HandleFunc("GET /login", handleLoginPage)
mux.HandleFunc("GET /logout", handleLogout)
// Static assets (public)
mux.Handle("GET /assets/", http.StripPrefix("/assets/", http.FileServer(http.Dir("dist/assets"))))
// Protected routes
protected := http.NewServeMux()
protected.HandleFunc("GET /{$}", handleIndex)
protected.HandleFunc("GET /tools/kostenrechner", handleKostenrechnerPage)
protected.HandleFunc("POST /api/tools/kostenrechner", handleKostenrechnerAPI)
protected.HandleFunc("GET /tools/fristenrechner", handleFristenrechnerPage)
protected.HandleFunc("POST /api/tools/fristenrechner", handleFristenrechnerAPI)
protected.HandleFunc("GET /api/tools/proceeding-types", handleProceedingTypes)
protected.HandleFunc("GET /downloads", handleDownloadsPage)
protected.HandleFunc("GET /glossar", handleGlossarPage)
protected.HandleFunc("GET /api/glossar", handleGlossarAPI)
protected.HandleFunc("POST /api/glossar/suggest", handleGlossarSuggest)
protected.HandleFunc("GET /files/{filename}", handleFileDownload)
protected.HandleFunc("POST /api/files/refresh", handleFileRefresh)
mux.Handle("/", client.Middleware(protected))
}
func handleIndex(w http.ResponseWriter, r *http.Request) {
http.ServeFile(w, r, "dist/index.html")
}
func writeJSON(w http.ResponseWriter, status int, data any) {
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(status)
json.NewEncoder(w).Encode(data)
}