1
0
Fork 0
empact/task/common.go

28 lines
529 B
Go

package task
import (
"code.google.com/p/goauth2/oauth"
"github.com/google/go-github/github"
"github.com/localhots/empact/db"
)
func newGithubClient(token string) *github.Client {
trans := &oauth.Transport{
Token: &oauth.Token{AccessToken: token},
}
return github.NewClient(trans.Client())
}
func saveResponseMeta(token string, res *github.Response) {
if res == nil {
return
}
tok := &db.Token{
Token: token,
Limit: res.Limit,
Remaining: res.Remaining,
ResetAt: res.Reset.Time,
}
tok.Save()
}