Add pre/post interceptor hooks to grpcserver.New

New Options parameter with PreInterceptors and PostInterceptors
allows services to inject custom interceptors into the chain:

  [pre-interceptors] → logging → auth → [post-interceptors] → handler

This enables services like metacrypt to add seal-check (pre-auth)
and audit-logging (post-auth) interceptors while using the shared
auth and logging infrastructure.

Pass nil for the default chain (logging + auth only).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-26 14:21:29 -07:00
parent 20d8d8d4b4
commit ee88ebecf2
2 changed files with 32 additions and 8 deletions

View File

@@ -216,7 +216,7 @@ func TestNewWithoutTLS(t *testing.T) {
defer srv.Close()
a := testAuth(t, srv.URL)
s, err := New("", "", a, testMethods, slog.Default())
s, err := New("", "", a, testMethods, slog.Default(), nil)
if err != nil {
t.Fatalf("New: %v", err)
}