Ensuring pdf routes work

This commit is contained in:
Finley Ghosh 2026-01-12 23:19:27 +11:00
parent fe1fc9ce77
commit 091ce77c49

View file

@ -71,13 +71,6 @@ func main() {
// Static files // Static files
goRouter.PathPrefix("/static/").Handler(http.StripPrefix("/go/static/", http.FileServer(http.Dir("static")))) goRouter.PathPrefix("/static/").Handler(http.StripPrefix("/go/static/", http.FileServer(http.Dir("static"))))
// PDF files - use PDF_OUTPUT_DIR env var or fallback to relative path
pdfDir := os.Getenv("PDF_OUTPUT_DIR")
if pdfDir == "" {
pdfDir = "webroot/pdf"
}
goRouter.PathPrefix("/pdf/").Handler(http.StripPrefix("/go/pdf/", http.FileServer(http.Dir(pdfDir))))
// Quote routes // Quote routes
goRouter.HandleFunc("/quotes", quoteHandler.QuotesOutstandingView).Methods("GET") goRouter.HandleFunc("/quotes", quoteHandler.QuotesOutstandingView).Methods("GET")
goRouter.HandleFunc("/quotes/send-reminder", quoteHandler.SendManualReminder).Methods("POST") goRouter.HandleFunc("/quotes/send-reminder", quoteHandler.SendManualReminder).Methods("POST")
@ -89,7 +82,7 @@ func main() {
goRouter.HandleFunc("/attachments/{id}", attachmentHandler.Get).Methods("GET") goRouter.HandleFunc("/attachments/{id}", attachmentHandler.Get).Methods("GET")
goRouter.HandleFunc("/attachments/{id}", attachmentHandler.Delete).Methods("DELETE") goRouter.HandleFunc("/attachments/{id}", attachmentHandler.Delete).Methods("DELETE")
// PDF generation endpoints - called from PHP app // PDF generation routes
goRouter.HandleFunc("/pdf/generate-invoice", handlers.GenerateInvoicePDF).Methods("POST") goRouter.HandleFunc("/pdf/generate-invoice", handlers.GenerateInvoicePDF).Methods("POST")
goRouter.HandleFunc("/pdf/generate-quote", handlers.GenerateQuotePDF).Methods("POST") goRouter.HandleFunc("/pdf/generate-quote", handlers.GenerateQuotePDF).Methods("POST")
goRouter.HandleFunc("/pdf/generate-po", handlers.GeneratePurchaseOrderPDF).Methods("POST") goRouter.HandleFunc("/pdf/generate-po", handlers.GeneratePurchaseOrderPDF).Methods("POST")
@ -97,6 +90,13 @@ func main() {
goRouter.HandleFunc("/pdf/generate-orderack", handlers.GenerateOrderAckPDF).Methods("POST") goRouter.HandleFunc("/pdf/generate-orderack", handlers.GenerateOrderAckPDF).Methods("POST")
goRouter.HandleFunc("/pdf/count-pages", handlers.CountPages).Methods("POST") goRouter.HandleFunc("/pdf/count-pages", handlers.CountPages).Methods("POST")
// Serve generated PDFs
pdfDir := os.Getenv("PDF_OUTPUT_DIR")
if pdfDir == "" {
pdfDir = "webroot/pdf"
}
goRouter.PathPrefix("/pdf/").Handler(http.StripPrefix("/go/pdf/", http.FileServer(http.Dir(pdfDir))))
// The following routes are currently disabled: // The following routes are currently disabled:
/* /*
// API routes // API routes