diff --git a/src/main.go b/src/main.go index 77c17f7..66820c0 100644 --- a/src/main.go +++ b/src/main.go @@ -1,11 +1,20 @@ package main import ( + "fmt" "log" "net/http" + "os" + + "github.com/joho/godotenv" ) func main() { + err := godotenv.Load(".env") + if err != nil { + log.Fatalf("Error occurred loading env variables: %s", err) + } + mux := http.NewServeMux() mux.HandleFunc("GET /oauthdemo", func(w http.ResponseWriter, r *http.Request) { @@ -27,7 +36,7 @@ func main() { w.Write([]byte(html)) }) - log.Println("Running on http://localhost:8001") - log.Println("Try oauth demo on http://localhost:8001/oauthdemo") - log.Fatal(http.ListenAndServe("0.0.0.0:8001", mux)) + log.Printf("Running on http://%s:%s\n", os.Getenv("HOST"), os.Getenv("PORT")) + log.Printf("Try oauth demo on http://%s:%s/oauthdemo\n", os.Getenv("HOST"), os.Getenv("PORT")) + log.Fatal(http.ListenAndServe(fmt.Sprintf("0.0.0.0:%s", os.Getenv("PORT")), mux)) } diff --git a/src/oauthdemo.go b/src/oauthdemo.go index 9132385..040bd5c 100644 --- a/src/oauthdemo.go +++ b/src/oauthdemo.go @@ -21,10 +21,10 @@ import ( var googleOauthConfig *oauth2.Config type User struct { - ID string `json:"id"` - Email string `json:"email"` - VerifiedEmail bool `json:"verified_email"` - Picture string `json:"picture"` + Id string `json:"id"` + Email string `json:"email"` + IsEmailVerified bool `json:"verified_email"` + Picture string `json:"picture"` } func init() { @@ -35,7 +35,7 @@ func init() { // Initialize the OAuth2 config once during package initialization googleOauthConfig = &oauth2.Config{ - RedirectURL: "http://localhost:8001/google-oauth-callback", + RedirectURL: fmt.Sprintf("http://%s:%s/google-oauth-callback", os.Getenv("HOST"), os.Getenv("PORT")), ClientID: os.Getenv("GOOGLE_CLIENT_ID"), ClientSecret: os.Getenv("GOOGLE_CLIENT_SECRET"), Scopes: []string{ @@ -135,12 +135,13 @@ func getAsHtml(userData []byte) (string, error) {

Oauth2 Demo

+

Google sign-in succesful!

- + %s
- + %s
@@ -154,7 +155,7 @@ func getAsHtml(userData []byte) (string, error) { - `, user.ID, user.Email, user.VerifiedEmail, user.Picture) + `, user.Email, user.Id, user.IsEmailVerified, user.Picture) return html, nil } diff --git a/src/server_metrics.go b/src/server_metrics.go index da590dd..e1c2df5 100644 --- a/src/server_metrics.go +++ b/src/server_metrics.go @@ -114,6 +114,9 @@ func generateServerStatusHTML(metrics ServerMetrics) string { .secondary { color: #9c83ff; } + .secondary:hover { + text-decoration: underline; + } 😈️ pointless-status 😈 @@ -139,6 +142,16 @@ func generateServerStatusHTML(metrics ServerMetrics) string {
Memory usage
%s
+
+ + +