mirror of
https://github.com/kevin-DL/services.git
synced 2026-01-20 22:45:09 +00:00
Add YouTube search (#241)
This commit is contained in:
35
youtube/main.go
Normal file
35
youtube/main.go
Normal file
@@ -0,0 +1,35 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/micro/micro/v3/service"
|
||||
"github.com/micro/micro/v3/service/config"
|
||||
"github.com/micro/micro/v3/service/logger"
|
||||
"github.com/micro/services/youtube/handler"
|
||||
pb "github.com/micro/services/youtube/proto"
|
||||
)
|
||||
|
||||
func main() {
|
||||
// Create service
|
||||
srv := service.New(
|
||||
service.Name("youtube"),
|
||||
service.Version("latest"),
|
||||
)
|
||||
|
||||
// Setup google maps
|
||||
c, err := config.Get("google.apikey")
|
||||
if err != nil {
|
||||
logger.Fatalf("Error loading config: %v", err)
|
||||
}
|
||||
apiKey := c.String("")
|
||||
if len(apiKey) == 0 {
|
||||
logger.Fatalf("Missing required config: google.apikey")
|
||||
}
|
||||
|
||||
// Register handler
|
||||
pb.RegisterYoutubeHandler(srv.Server(), handler.New(apiKey))
|
||||
|
||||
// Run service
|
||||
if err := srv.Run(); err != nil {
|
||||
logger.Fatal(err)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user