check / check (push) Waiting to run
`internal/handlers/source_management.go` had grown to about 2,370 lines holding the webhook, event log, entrypoint and target handlers, so unrelated units had to wait on each other to touch it. It is split, as pure code movement, into files named for what they hold: `webhook_list.go`, `webhook_create.go`, `webhook_detail.go`, `webhook_edit.go`, `webhook_delete.go`, `event_log.go`, `entrypoint.go`, `target_create.go`, `target_delete.go`, `target_toggle.go` and `shared.go`. No function body, signature, comment or behaviour changed. The README's file tree and log-line caveat, and one middleware comment, name the new files. Model: opus-5-5
32 lines
822 B
Go
32 lines
822 B
Go
package handlers
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"sneak.berlin/go/webhooker/internal/database"
|
|
)
|
|
|
|
// HandleTargetDelete handles deleting a target. A deleted
|
|
// database target's archive writer is evicted and its handle
|
|
// closed; the archive file is left on disk.
|
|
func (h *Handlers) HandleTargetDelete() http.HandlerFunc {
|
|
return h.deleteChildResource(
|
|
"targetID", &database.Target{},
|
|
"failed to delete target",
|
|
h.evictTargetArchiveWriter,
|
|
targetDeleted,
|
|
)
|
|
}
|
|
|
|
// evictTargetArchiveWriter is evictArchiveWriter for one deleted
|
|
// target, and leaves its archive file on disk for the same reason.
|
|
// A target that is not a database target has no writer, and
|
|
// evicting it does nothing.
|
|
func (h *Handlers) evictTargetArchiveWriter(targetID string) {
|
|
if h.archives == nil {
|
|
return
|
|
}
|
|
|
|
h.archives.EvictTarget(targetID)
|
|
}
|