mirror of
https://github.com/kevin-DL/services.git
synced 2026-01-14 20:14:47 +00:00
add google search (#242)
* add google search * fix git ignore * Charge 1c for search queries
This commit is contained in:
44
google/main.go
Normal file
44
google/main.go
Normal file
@@ -0,0 +1,44 @@
|
||||
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/google/handler"
|
||||
pb "github.com/micro/services/google/proto"
|
||||
)
|
||||
|
||||
func main() {
|
||||
// Create service
|
||||
srv := service.New(
|
||||
service.Name("google"),
|
||||
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")
|
||||
}
|
||||
// Setup google maps
|
||||
c, err = config.Get("google.cx_id")
|
||||
if err != nil {
|
||||
logger.Fatalf("Error loading config: %v", err)
|
||||
}
|
||||
cxId := c.String("")
|
||||
if len(cxId) == 0 {
|
||||
logger.Fatalf("Missing required config: google.cxId")
|
||||
}
|
||||
|
||||
// Register handler
|
||||
pb.RegisterGoogleHandler(srv.Server(), handler.New(apiKey, cxId))
|
||||
|
||||
// Run service
|
||||
if err := srv.Run(); err != nil {
|
||||
logger.Fatal(err)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user