File tree Expand file tree Collapse file tree 3 files changed +10
-4
lines changed
Expand file tree Collapse file tree 3 files changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -33,6 +33,5 @@ USER nonroot
3333EXPOSE 8080
3434
3535COPY --from=builder /go/bin/auth0-cas-server-go /auth0-cas-server-go
36- COPY --from=builder /build/templates /templates
3736
3837ENTRYPOINT ["/auth0-cas-server-go" , "-p=8080" ]
Original file line number Diff line number Diff line change @@ -84,6 +84,9 @@ func main() {
8484 logger := slog .New (handler )
8585 slog .SetDefault (logger )
8686
87+ // Initialize error template after logging is set up.
88+ initErrorTemplate ()
89+
8790 // Instrument Open Telemetry.
8891 if ! * noTrace {
8992 // Start OTLP forwarder and register the global tracing provider.
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ package main
77// spell-checker:disable
88import (
99 "context"
10+ _ "embed"
1011 "encoding/json"
1112 "encoding/xml"
1213 "errors"
8081
8182 // spell-checker:enable
8283
84+ //go:embed templates/error.html
85+ errorTemplateContent string
8386 // errorTemplate is the HTML template for error pages.
8487 errorTemplate * template.Template
8588)
@@ -91,10 +94,11 @@ type ErrorPageData struct {
9194 ShowBackButton bool
9295}
9396
94- // init initializes the error page template.
95- func init () {
97+ // initErrorTemplate initializes the error page template from embedded content.
98+ // This should be called from main() after logging is set up.
99+ func initErrorTemplate () {
96100 var err error
97- errorTemplate , err = template .ParseFiles ( "templates/ error.html" )
101+ errorTemplate , err = template .New ( " error.html"). Parse ( errorTemplateContent )
98102 if err != nil {
99103 // Log error but don't fail - we'll fall back to plain text errors.
100104 // This allows the service to start even if templates are missing.
You can’t perform that action at this time.
0 commit comments