-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.go
37 lines (30 loc) · 785 Bytes
/
app.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package main
import (
"YouTubeZen/backend"
"context"
"net/http"
"google.golang.org/api/youtube/v3"
)
var client *http.Client
var service *youtube.Service
// App struct
type App struct {
ctx context.Context
}
// NewApp creates a new App application struct
func NewApp() *App {
return &App{}
}
// startup is called when the app starts. The context is saved
// so we can call the runtime methods
func (a *App) startup(ctx context.Context) {
a.ctx = ctx
scope := youtube.YoutubeReadonlyScope
client = backend.GetClient(scope)
service = backend.Initialize(client)
}
// Search calls the SearchYoutube function from the backend package
func (a *App) Search(query string) ([]map[string]string, error) {
results := backend.SearchYouTube(service, query)
return results, nil
}