set token earlier
This commit is contained in:
parent
d6c59aef3a
commit
dbcf63674c
24
main.go
24
main.go
@ -113,6 +113,20 @@ func main() {
|
||||
r.Use(middleware.Logger)
|
||||
r.Use(OwnerCtx)
|
||||
|
||||
ghToken := os.Getenv("GH_AUTH_TOKEN")
|
||||
|
||||
if *tokenFile != "" && ghToken == "" {
|
||||
tfBytes, err := os.ReadFile(*tokenFile)
|
||||
if err != nil {
|
||||
log.Fatal("can't read token file: ", err)
|
||||
}
|
||||
ghToken = string(tfBytes)
|
||||
}
|
||||
|
||||
if ghToken == "" {
|
||||
log.Fatal("can't operate without GH_AUTH_TOKEN")
|
||||
}
|
||||
|
||||
var liveServer http.Handler
|
||||
if *dev {
|
||||
liveServer = http.FileServer(http.Dir("./assets"))
|
||||
@ -149,16 +163,6 @@ func main() {
|
||||
r.Get("/{linkID:[0-9]+}", iconGET)
|
||||
})
|
||||
|
||||
ghToken := os.Getenv("GH_AUTH_TOKEN")
|
||||
|
||||
if *tokenFile != "" && ghToken == "" {
|
||||
tfBytes, err := os.ReadFile(*tokenFile)
|
||||
if err != nil {
|
||||
log.Fatal("can't read token file: ", err)
|
||||
}
|
||||
ghToken = string(tfBytes)
|
||||
}
|
||||
|
||||
go func() {
|
||||
for {
|
||||
if dbExists && ghToken != "" {
|
||||
|
@ -115,6 +115,9 @@ func (w WatchResults) GetLimits() *RateLimit {
|
||||
}
|
||||
|
||||
func UpdateWatches(ghToken string) (*WatchResults, error) {
|
||||
if ghToken == "" {
|
||||
return nil, fmt.Errorf("invalid github token")
|
||||
}
|
||||
ctx := context.Background()
|
||||
w := WatchResults{}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user