From 89e0741153f50675bb9c03f92ad5382ae5b5bf54 Mon Sep 17 00:00:00 2001 From: Lars Kiesow Date: Thu, 1 Feb 2024 01:29:37 +0100 Subject: [PATCH] Don't Crash on Request Error This patch prevents the application from crashing if the opencast server can not be reached, for example, due to a network outage. --- main.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index f5f1907..12d3b29 100644 --- a/main.go +++ b/main.go @@ -119,7 +119,8 @@ func setupRouter() *gin.Engine { req.SetBasicAuth(config.Opencast.Username, config.Opencast.Password) resp, err := client.Do(req) if err != nil { - log.Fatal(err) + c.JSON(http.StatusBadGateway, nil) + return } bodyText, err := ioutil.ReadAll(resp.Body) s := string(bodyText)