From a136d208d5d385af639f131651bd5c764aa2aa58 Mon Sep 17 00:00:00 2001 From: mo khan Date: Thu, 14 Apr 2022 10:14:09 -0600 Subject: read host from env var --- src/oidc/main.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/oidc/main.go b/src/oidc/main.go index 3c9f057..cca89f5 100644 --- a/src/oidc/main.go +++ b/src/oidc/main.go @@ -8,6 +8,7 @@ import ( "io/ioutil" "log" "net/http" + "os" "text/template" "time" @@ -126,7 +127,11 @@ func handler(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json") data, _ := ioutil.ReadFile("openid-configuration.json") tmpl, _ := template.New("test").Parse(string(data)) - tmpl.Execute(w, struct{ Host string }{Host: "http://localhost:8282"}) + host, ok := os.LookupEnv("HOST") + if !ok { + host = "http://localhost:8282" + } + tmpl.Execute(w, struct{ Host string }{Host: host}) } else if r.URL.Path == "/userinfo" { w.WriteHeader(http.StatusNotImplemented) } else if r.URL.Path == "/.well-known/jwks.json" { -- cgit v1.2.3