+6
main.go
+6
main.go
···
30
30
}
31
31
}
32
32
33
+
func home(w http.ResponseWriter, r *http.Request) {
34
+
w.Header().Set("Content-Type", "text/html")
35
+
w.Write([]byte("visit <a href='/login'>/login</a> to get started"))
36
+
}
37
+
33
38
func (o *OAuthService) HandleLogin(w http.ResponseWriter, r *http.Request) {
34
39
url := o.cfg.AuthCodeURL("state")
35
40
fmt.Println("Complete authorization at:", url)
···
91
96
92
97
oauthService := NewOAuthService()
93
98
99
+
http.HandleFunc("/", home)
94
100
http.HandleFunc("/login", oauthService.HandleLogin)
95
101
http.HandleFunc("/callback", oauthService.HandleCallback)
96
102