package main import ( "fmt" "net/http" "nucleus/internal/controllers" ) func main() { oauth2 := &controllers.Oauth2Controller{} oauth2.Init() // auth_server 授权入口 http.HandleFunc("/oauth2/authorize", oauth2.HandleAuthorizeRequest) // auth_server 发现未登录状态, 跳转到的登录handler http.HandleFunc("/oauth2/login", oauth2.HandleLoginRequest) // auth_server拿到 client以后重定向到的地址, 也就是 auth_client 获取到了code, 准备用code换取access_token //http.HandleFunc("/oauth2/code_to_token", internal.CodeToToken) // auth_server 处理由code 换取access token 的handler http.HandleFunc("/oauth2/token", oauth2.HandleAccessTokenRequest) // 登录完成, 同意授权的页面 http.HandleFunc("/oauth2/agree-auth", oauth2.HandleAgreeAuthRequest) // access token 换取用户信息的handler http.HandleFunc("/oauth2/userinfo", oauth2.HandleUserInfoRequest) http.Handle("/", http.FileServer(http.Dir("./static"))) errChan := make(chan error) go func() { errChan <- http.ListenAndServe(":9001", nil) }() err := <-errChan if err != nil { fmt.Println("Hello internal stop running.") } }