Skip to content

Commit

Permalink
add readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Birjemin committed Dec 27, 2020
1 parent 5a3815e commit 2fbf3fe
Showing 1 changed file with 42 additions and 42 deletions.
84 changes: 42 additions & 42 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,51 +18,51 @@ go get github.com/birjemin/go-socialite

```golang
var (
httpClient = &utils.HTTPClient{
Client: &http.Client{
Timeout: 5 * time.Second,
},
}

defaultObj = &socialite.Default{}

qqObj = &socialite.Qq{
AppID: "",
AppSecret: "",
RedirectURL: "https://domain/qq/callback",
HTTPRequest: httpClient,
}

wxObj = &socialite.Wechat{
AppID: "",
AppSecret: "",
RedirectURL: "https://domain/qq/callback",
HTTPRequest: httpClient,
}

wbObj = &socialite.Weibo{
ClientID: "",
ClientSecret: "",
RedirectURL: "http://domain.com/wb/callback",
HTTPRequest: httpClient,
}
httpClient = &utils.HTTPClient{
Client: &http.Client{
Timeout: 5 * time.Second,
},
}

defaultObj = &socialite.Default{}

qqObj = &socialite.Qq{
AppID: "",
AppSecret: "",
RedirectURL: "https://domain/qq/callback",
HTTPRequest: httpClient,
}

wxObj = &socialite.Wechat{
AppID: "",
AppSecret: "",
RedirectURL: "https://domain/qq/callback",
HTTPRequest: httpClient,
}

wbObj = &socialite.Weibo{
ClientID: "",
ClientSecret: "",
RedirectURL: "http://domain.com/wb/callback",
HTTPRequest: httpClient,
}
)

func dispatch(platform string) socialite.ISocialite {
var obj socialite.ISocialite

switch platform {
case "qq":
obj = qqObj
case "wx":
obj = wxObj
case "wb":
obj = wbObj
default:
obj = defaultObj
}

return obj
var obj socialite.ISocialite

switch platform {
case "qq":
obj = qqObj
case "wx":
obj = wxObj
case "wb":
obj = wbObj
default:
obj = defaultObj
}

return obj
}
obj := dispatch("wx")
// obj := dispatch("wb")
Expand Down

0 comments on commit 2fbf3fe

Please sign in to comment.