RegisterAttachmentAPI registers attachment list/download/preview endpoints. Routes are namespaced under a literal `attachments` segment rather than `/api/{module}/{eventUuid}/attachments/...`. The previous layout used a wildcard at position 2, which collides with module routes like `/api/smtp/messa
(mux *http.ServeMux, db *sql.DB, store *storage.AttachmentStore)
| 16 | // `/api/smtp/message/{uuid}/raw` (both 4-segment patterns, neither more |
| 17 | // specific) and made the server panic at startup. |
| 18 | func RegisterAttachmentAPI(mux *http.ServeMux, db *sql.DB, store *storage.AttachmentStore) { |
| 19 | // SMTP attachments. |
| 20 | registerAttachmentsForModule(mux, db, store, "/api/smtp/attachments", "smtp_attachments") |
| 21 | |
| 22 | // HTTP Dump attachments (support both /http-dump/ and /http-dumps/ paths |
| 23 | // for backwards compatibility with existing clients). |
| 24 | registerAttachmentsForModule(mux, db, store, "/api/http-dump/attachments", "http_dump_attachments") |
| 25 | registerAttachmentsForModule(mux, db, store, "/api/http-dumps/attachments", "http_dump_attachments") |
| 26 | } |
| 27 | |
| 28 | func registerAttachmentsForModule(mux *http.ServeMux, db *sql.DB, store *storage.AttachmentStore, prefix, table string) { |
| 29 | mux.HandleFunc("GET "+prefix+"/{uuid}", listAttachments(db, table)) |
nothing calls this directly
no test coverage detected