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:
@ -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
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user