Added error 503 popup
This commit is contained in:
@@ -6,12 +6,11 @@ import (
|
||||
"time"
|
||||
|
||||
"projectreshoot/db"
|
||||
"projectreshoot/view/page"
|
||||
|
||||
"github.com/rs/zerolog"
|
||||
)
|
||||
|
||||
func WithTransaction(
|
||||
func removeme(
|
||||
w http.ResponseWriter,
|
||||
r *http.Request,
|
||||
logger *zerolog.Logger,
|
||||
@@ -22,6 +21,7 @@ func WithTransaction(
|
||||
w http.ResponseWriter,
|
||||
r *http.Request,
|
||||
),
|
||||
onfail func(err error),
|
||||
) {
|
||||
ctx, cancel := context.WithTimeout(r.Context(), 15*time.Second)
|
||||
defer cancel()
|
||||
@@ -29,13 +29,7 @@ func WithTransaction(
|
||||
// Start the transaction
|
||||
tx, err := conn.Begin(ctx)
|
||||
if err != nil {
|
||||
logger.Warn().Err(err).Msg("Request failed to start a transaction")
|
||||
w.WriteHeader(http.StatusServiceUnavailable)
|
||||
page.Error(
|
||||
"503",
|
||||
http.StatusText(503),
|
||||
"This service is currently unavailable. It could be down for maintenance").
|
||||
Render(r.Context(), w)
|
||||
onfail(err)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user