Skip to content

Commit

Permalink
Listen and serve on https
Browse files Browse the repository at this point in the history
  • Loading branch information
foot committed Feb 18, 2022
1 parent 756a3a8 commit b27ebdd
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion cmd/gitops/ui/run/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"embed"
"fmt"
"io/fs"
"log"
"net"
"net/http"
"net/url"
Expand Down Expand Up @@ -265,7 +266,7 @@ func runCmd(cmd *cobra.Command, args []string) error {
go func() {
log.Infof("Serving on port %s", options.Port)

if err := srv.ListenAndServe(); err != nil {
if err := listenAndServe(srv, options); err != nil {
log.Error(err, "server exited")
os.Exit(1)
}
Expand Down Expand Up @@ -299,6 +300,17 @@ func runCmd(cmd *cobra.Command, args []string) error {
return nil
}

func listenAndServe(srv *http.Server, options Options) error {
if options.NoTLS {
log.Println("TLS connections disabled")
return srv.ListenAndServe()
}

log.Printf("Using TLS from %q and %q", options.TlsCert, options.TlsKey)

return srv.ListenAndServeTLS(options.TlsCert, options.TlsKey)
}

//go:embed dist/*
var static embed.FS

Expand Down

0 comments on commit b27ebdd

Please sign in to comment.