add sender to template data for relevant modules

This commit is contained in:
Joel Wetzell
2026-03-04 19:38:30 -06:00
parent dff33f722d
commit 38b8e44f04
5 changed files with 22 additions and 3 deletions

View File

@@ -6,6 +6,7 @@ import (
"errors"
"fmt"
"log/slog"
"net"
"net/http"
"github.com/jwetzell/showbridge-go/internal/common"
@@ -84,6 +85,10 @@ func (hs *HTTPServer) ServeHTTP(w http.ResponseWriter, r *http.Request) {
}
if hs.router != nil {
inputContext := context.WithValue(hs.ctx, httpServerContextKey("responseWriter"), &responseWriter)
senderAddr, err := net.ResolveTCPAddr("tcp", r.RemoteAddr)
if err == nil {
inputContext = context.WithValue(inputContext, common.SenderContextKey, senderAddr)
}
aRouteFound, routingErrors := hs.router.HandleInput(inputContext, hs.Id(), r)
if !responseWriter.done {
if aRouteFound {