Add Middleware Support

This commit is contained in:
2025-01-28 14:32:27 -05:00
parent 06bf7ebca7
commit 896225effc
2 changed files with 39 additions and 17 deletions

View File

@ -3,6 +3,7 @@ package app
import (
"context"
"errors"
"net/http"
"github.com/rs/zerolog"
"go.opentelemetry.io/otel/codes"
@ -25,6 +26,7 @@ type App struct {
type AppHTTP struct {
Funcs []srv.HTTPFunc
Middleware []http.Handler
HealthChecks []srv.HealthCheckFunc
httpDone <-chan interface{}
}
@ -78,9 +80,12 @@ func (a *App) MustRun() {
func (a *App) initHTTP() {
var httpShutdown shutdownFunc
httpShutdown, a.HTTP.httpDone = srv.MustInitHTTPServer(
a.AppContext,
a.HTTP.Funcs,
a.HTTP.HealthChecks...,
&srv.HTTPServerOpts{
Ctx: a.AppContext,
HandleFuncs: a.HTTP.Funcs,
Middleware: a.HTTP.Middleware,
HealthCheckFuncs: a.HTTP.HealthChecks,
},
)
a.shutdownFuncs = append(a.shutdownFuncs, httpShutdown)
}