Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions proxy/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ func main() {

tlsConfig, err := bridge.GetTlsConfig()
if err != nil {
panic(err)
log.WithError(err).Error("Failed to get TLS configuration")
os.Exit(1)
}

apiRouter.Handle("/flightctl/{forward:.*}", bridge.NewFlightCtlHandler(tlsConfig))
Expand Down Expand Up @@ -73,7 +74,8 @@ func main() {
if config.OcpPlugin != "true" {
authHandler, err := auth.NewAuth(tlsConfig)
if err != nil {
panic(err)
log.WithError(err).Error("Failed to initialize authentication")
os.Exit(1)
}
apiRouter.HandleFunc("/login", authHandler.Login)
apiRouter.HandleFunc("/login/info", authHandler.GetUserInfo)
Expand All @@ -92,7 +94,8 @@ func main() {
if config.TlsKeyPath != "" && config.TlsCertPath != "" {
cert, err := tls.LoadX509KeyPair(config.TlsCertPath, config.TlsKeyPath)
if err != nil {
panic(err)
log.WithError(err).Error("Failed to load TLS certificate")
os.Exit(1)
}
serverTlsconfig = &tls.Config{
Certificates: []tls.Certificate{cert},
Expand Down
5 changes: 4 additions & 1 deletion proxy/bridge/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ import (
"net/http"
"net/http/httputil"
"net/url"
"os"

"github.com/gorilla/mux"

"github.com/flightctl/flightctl-ui/config"
"github.com/flightctl/flightctl-ui/log"
)

type handler struct {
Expand All @@ -28,7 +30,8 @@ func (h handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
func createReverseProxy(apiURL string) (*url.URL, *httputil.ReverseProxy) {
target, err := url.Parse(apiURL)
if err != nil {
panic(err)
log.GetLogger().WithError(err).Errorf("Failed to parse URL '%s'", apiURL)
os.Exit(1)
}
proxy := httputil.NewSingleHostReverseProxy(target)
proxy.ModifyResponse = func(r *http.Response) error {
Expand Down