Add /llms.txt endpoint to trust center compliance page
Renders compliance data (frameworks, documents, audits, subprocessors, references, and external links) as a plain-text Markdown document. The endpoint supports all required visibility filters and pagination. Signed-off-by: Bryan Frimin <bryan@getprobo.com>
This commit is contained in:
43
pkg/server/api/compliancepage/markdown_handler.go
Normal file
43
pkg/server/api/compliancepage/markdown_handler.go
Normal file
@@ -0,0 +1,43 @@
|
||||
// Copyright (c) 2026 Probo Inc <hello@getprobo.com>.
|
||||
//
|
||||
// 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/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")
|
||||
|
||||
if err := h.trustService.RenderCompliancePageMarkdown(r.Context(), w, tc.ID, tc.TenantID); err != nil {
|
||||
http.Error(w, "internal server error", http.StatusInternalServerError)
|
||||
}
|
||||
}
|
||||
@@ -174,7 +174,10 @@ func (s *Server) stripTrustPrefix(next http.Handler) http.Handler {
|
||||
func (s *Server) trustCenterRouter() chi.Router {
|
||||
r := chi.NewRouter()
|
||||
|
||||
h := compliancepage.NewHandler(s.trustService)
|
||||
|
||||
r.Mount("/api/trust/v1", s.apiServer.CompliancePageHandler())
|
||||
r.Get("/llms.txt", h.HandleLLMsTxt)
|
||||
r.Handle("/*", s.trustWebServer)
|
||||
|
||||
return r
|
||||
|
||||
Reference in New Issue
Block a user