1
0
forked from wrenn/wrenn

Add MiddlewareProvider interface for extension middleware

Allows cloud extensions to inject middleware that wraps OSS routes
(e.g. billing enforcement) before they are registered.
This commit is contained in:
2026-04-18 14:47:29 +06:00
parent 8f8638e6db
commit 47be1143fb

View File

@ -5,6 +5,7 @@ package cpextension
import ( import (
"context" "context"
"net/http"
"github.com/go-chi/chi/v5" "github.com/go-chi/chi/v5"
"github.com/jackc/pgx/v5/pgxpool" "github.com/jackc/pgx/v5/pgxpool"
@ -48,3 +49,10 @@ type Extension interface {
// Each function should start its own goroutine(s) and return. // Each function should start its own goroutine(s) and return.
BackgroundWorkers(ctx ServerContext) []func(context.Context) BackgroundWorkers(ctx ServerContext) []func(context.Context)
} }
// MiddlewareProvider is optionally implemented by extensions that need
// middleware applied before OSS routes are registered. This allows
// cloud middleware to wrap existing OSS routes (e.g. billing checks).
type MiddlewareProvider interface {
Middlewares(ctx ServerContext) []func(http.Handler) http.Handler
}