package web import ( "fmt" "net/http" "github.com/netcell-it/deklarix/internal/extract" "github.com/netcell-it/deklarix/internal/rules" ) func (s *Server) handleHealth(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json") fmt.Fprint(w, `{"ok":true}`) } type indexData struct { Title string } func (s *Server) handleIndex(w http.ResponseWriter, r *http.Request) { if err := s.templates.ExecuteTemplate(w, "layout", indexData{Title: "Pre-Publish-Prüfung"}); err != nil { http.Error(w, "Seite konnte nicht gerendert werden", http.StatusInternalServerError) } } type findingView struct { RuleID string Version int Severity string Title string Fix string Sources []string } type resultData struct { NeedsClarification bool Findings []findingView } // handleCheck führt die Pre-Publish-Prüfung aus: Extraktion (Stufe 1) // gefolgt von der Regelauswertung (Stufe 2). Speichert noch nichts — // das ist der nächste Schritt (Verdrahtung über internal/store). func (s *Server) handleCheck(w http.ResponseWriter, r *http.Request) { if err := r.ParseForm(); err != nil { http.Error(w, "ungültiges Formular", http.StatusBadRequest) return } platform := r.FormValue("platform") caption := r.FormValue("caption") if platform == "" || caption == "" { http.Error(w, "Plattform und Caption sind Pflichtfelder", http.StatusBadRequest) return } facts, err := s.extractor.Extract(r.Context(), extract.Input{ Platform: platform, Jurisdiction: "DE", Caption: caption, }) if err != nil { http.Error(w, "Extraktion fehlgeschlagen: "+err.Error(), http.StatusBadGateway) return } findings, needsClarification := rules.Evaluate(s.ruleSet, facts) data := resultData{NeedsClarification: needsClarification} for _, f := range findings { data.Findings = append(data.Findings, findingView{ RuleID: f.RuleID, Version: f.RuleVersion, Severity: string(f.Severity), Title: f.Title, Fix: f.Fix, Sources: f.Sources, }) } if err := s.templates.ExecuteTemplate(w, "result", data); err != nil { http.Error(w, "Ergebnis konnte nicht gerendert werden", http.StatusInternalServerError) } }