// Copyright (c) 2026 Probo Inc . // // Permission to use, copy, modify, and/or distribute this software for any // purpose with or without fee is hereby granted, provided that the above // copyright notice and this permission notice appear in all copies. // // THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH // REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY // AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, // INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM // LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR // OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR // PERFORMANCE OF THIS SOFTWARE. package compliancepage import ( "net/http" "go.probo.inc/probo/pkg/coredata" "go.probo.inc/probo/pkg/trust" ) type Handler struct { trustService *trust.Service } func NewHandler(trustService *trust.Service) *Handler { return &Handler{trustService: trustService} } func (h *Handler) HandleLLMsTxt(w http.ResponseWriter, r *http.Request) { tc := CompliancePageFromContext(r.Context()) if tc == nil { http.Error(w, "not found", http.StatusNotFound) return } w.Header().Set("Content-Type", "text/plain; charset=utf-8") scope := coredata.NewScopeFromObjectID(tc.ID) if err := h.trustService.RenderCompliancePageMarkdown(r.Context(), w, tc.ID, scope); err != nil { http.Error(w, "internal server error", http.StatusInternalServerError) } } func (h *Handler) HandleRobotsTxt(w http.ResponseWriter, r *http.Request) { tc := CompliancePageFromContext(r.Context()) if tc == nil { http.Error(w, "not found", http.StatusNotFound) return } baseURL := CompliancePageBaseURLFromContext(r.Context()) if baseURL == nil { http.Error(w, "not found", http.StatusNotFound) return } w.Header().Set("Content-Type", "text/plain; charset=utf-8") if err := h.trustService.RenderRobotsTxt(r.Context(), w, tc.SearchEngineIndexing, *baseURL); err != nil { http.Error(w, "internal server error", http.StatusInternalServerError) } } func (h *Handler) HandleSitemap(w http.ResponseWriter, r *http.Request) { tc := CompliancePageFromContext(r.Context()) if tc == nil { http.Error(w, "not found", http.StatusNotFound) return } baseURL := CompliancePageBaseURLFromContext(r.Context()) if baseURL == nil { http.Error(w, "not found", http.StatusNotFound) return } w.Header().Set("Content-Type", "application/xml; charset=utf-8") scope := coredata.NewScopeFromObjectID(tc.ID) if err := h.trustService.RenderSitemap(r.Context(), w, tc.ID, scope, *baseURL); err != nil { http.Error(w, "internal server error", http.StatusInternalServerError) } }