| package main |
| |
| import ( |
| "flag" |
| "net/http" |
| |
| "github.com/golang/glog" |
| "github.com/grpc-ecosystem/grpc-gateway/runtime" |
| "golang.org/x/net/context" |
| "google.golang.org/grpc" |
| |
| gw "android_emulation_control" |
| ) |
| |
| var ( |
| emulatorEndpoint = flag.String("emulator_endpoint", "localhost:5556", "endpoint of the emulator") |
| ) |
| |
| func run() error { |
| ctx := context.Background() |
| ctx, cancel := context.WithCancel(ctx) |
| defer cancel() |
| |
| mux := runtime.NewServeMux() |
| opts := []grpc.DialOption{grpc.WithMaxMsgSize(8 * 1024 * 1024), grpc.WithInsecure()} |
| |
| err := gw.RegisterEmulatorControllerHandlerFromEndpoint(ctx, mux, *emulatorEndpoint, opts) |
| if err != nil { |
| return err |
| } |
| |
| return http.ListenAndServe(":8080", mux) |
| } |
| |
| func main() { |
| flag.Parse() |
| defer glog.Flush() |
| |
| if err := run(); err != nil { |
| glog.Fatal(err) |
| } |
| } |