refactor: move proxy block message rendering to presentation layer (#364)

* refactor: move proxy block message rendering to presentation layer

* refactor: introduce ui.ProxyPresenter with injected advisory source

* feat: friendly ecosystem labels in proxy block messages

* test: cover ecosystemLabel derivation

* fix: address review feedback on block context assertions and empty reference line
This commit is contained in:
Sahil Bansal
2026-07-10 17:42:26 +05:30
committed by GitHub
parent 2f1c348a06
commit 31e51b10dd
12 changed files with 358 additions and 97 deletions
+8
View File
@@ -62,6 +62,11 @@ type ProxyConfig struct {
// Interceptors
Interceptors []Interceptor
// BlockMessageRenderer composes the response body for blocked requests
// from the interceptor's structured block decision. nil falls back to
// the generic block message.
BlockMessageRenderer func(BlockReason, *BlockContext) string
// Other configuration
EnableMITM bool
RequestTimeout time.Duration
@@ -561,6 +566,9 @@ func (ps *proxyServer) registerHandlers() {
}
message := resp.BlockMessage
if message == "" && ps.config.BlockMessageRenderer != nil {
message = ps.config.BlockMessageRenderer(resp.BlockReason, resp.BlockContext)
}
if message == "" {
message = "Blocked by proxy interceptor"
}