34 lines
738 B
Go
34 lines
738 B
Go
package app
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/rs/zerolog"
|
|
"go.opentelemetry.io/otel/attribute"
|
|
"go.opentelemetry.io/otel/codes"
|
|
"go.opentelemetry.io/otel/trace"
|
|
|
|
optshttp "gitea.libretechconsulting.com/rmcguire/go-app/pkg/srv/http/opts"
|
|
)
|
|
|
|
func (a *App) runHTTP(ctx context.Context) {
|
|
if a.HTTP == nil {
|
|
a.HTTP = &optshttp.AppHTTP{
|
|
HTTPDone: make(chan any),
|
|
}
|
|
}
|
|
|
|
if !a.cfg.HTTPEnabled() {
|
|
zerolog.Ctx(ctx).Info().Msg("skipping disabled HTTP Server")
|
|
return
|
|
}
|
|
|
|
span := trace.SpanFromContext(ctx)
|
|
if err := a.initHTTP(ctx); err != nil {
|
|
span.RecordError(err)
|
|
span.SetStatus(codes.Error, err.Error())
|
|
}
|
|
span.AddEvent("http server started")
|
|
span.SetAttributes(attribute.Int("http.handlers", len(a.HTTP.Funcs)))
|
|
}
|