MCPcopy Create free account
hub / github.com/buggregator/server / RegisterAttachmentAPI

Function RegisterAttachmentAPI

internal/server/http/attachments.go:18–26  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

16// `/api/smtp/message/{uuid}/raw` (both 4-segment patterns, neither more
17// specific) and made the server panic at startup.
18func 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
28func registerAttachmentsForModule(mux *http.ServeMux, db *sql.DB, store *storage.AttachmentStore, prefix, table string) {
29 mux.HandleFunc("GET "+prefix+"/{uuid}", listAttachments(db, table))

Callers

nothing calls this directly

Calls 1

Tested by

no test coverage detected