diff --git a/rest_gateway/README.md b/rest_gateway/README.md index ded3b2073..db358f543 100644 --- a/rest_gateway/README.md +++ b/rest_gateway/README.md @@ -8,7 +8,11 @@ This is a go serviced based on the official [grpc-gateway project](https://githu that compiles opencue's proto files into a go service that provides a REST interface and redirect calls to the grpc endpoint. -The service is available at http://opencue-gateway.apps.com +## Running the service + +Running the service is very simple: + * Read and modify the rest_gateway/Dockerfile according to your environment and build the gateway image using docker. + * Run the image providing the environment variable `CUEBOT_ENDPOINT=your.cuebot.server:8443` ## REST interface diff --git a/rest_gateway/opencue_gateway/main.go b/rest_gateway/opencue_gateway/main.go index 7ad10e532..55f8355a3 100644 --- a/rest_gateway/opencue_gateway/main.go +++ b/rest_gateway/opencue_gateway/main.go @@ -21,7 +21,7 @@ func getEnv(key, fallback string) string { } func run() error { - grpcServerEndpoint := getEnv("CUEBOT_ENDPOINT", "opencuetest01.spimageworks.com:8443") + grpcServerEndpoint := getEnv("CUEBOT_ENDPOINT", "opencuetest01.your.test.server:8443") port := getEnv("REST_PORT", "8448") ctx := context.Background() @@ -32,11 +32,49 @@ func run() error { // Note: Make sure the gRPC server is running properly and accessible mux := runtime.NewServeMux() opts := []grpc.DialOption{grpc.WithTransportCredentials(insecure.NewCredentials())} - err := gw.RegisterShowInterfaceHandlerFromEndpoint(ctx, mux, grpcServerEndpoint, opts) - if err != nil { - return err + + // show.proto + errShow := gw.RegisterShowInterfaceHandlerFromEndpoint(ctx, mux, grpcServerEndpoint, opts) + if errShow != nil { + return errShow } + errFrame := gw.RegisterFrameInterfaceHandlerFromEndpoint(ctx, mux, grpcServerEndpoint, opts) + if errFrame != nil { + return errFrame + } + errGroup := gw.RegisterGroupInterfaceHandlerFromEndpoint(ctx, mux, grpcServerEndpoint, opts) + if errGroup != nil { + return errGroup + } + errJob := gw.RegisterJobInterfaceHandlerFromEndpoint(ctx, mux, grpcServerEndpoint, opts) + if errJob != nil { + return errJob + } + errLayer := gw.RegisterLayerInterfaceHandlerFromEndpoint(ctx, mux, grpcServerEndpoint, opts) + if errLayer != nil { + return errLayer + } + + // host.proto + errDeed := gw.RegisterDeedInterfaceHandlerFromEndpoint(ctx, mux, grpcServerEndpoint, opts) + if errDeed != nil { + return errDeed + } + errHost := gw.RegisterHostInterfaceHandlerFromEndpoint(ctx, mux, grpcServerEndpoint, opts) + if errHost != nil { + return errHost + } + errOwner := gw.RegisterOwnerInterfaceHandlerFromEndpoint(ctx, mux, grpcServerEndpoint, opts) + if errOwner != nil { + return errOwner + } + errProc := gw.RegisterProcInterfaceHandlerFromEndpoint(ctx, mux, grpcServerEndpoint, opts) + if errProc != nil { + return errProc + } + + // Start HTTP server (and proxy calls to gRPC server endpoint) return http.ListenAndServe(":" + port, mux) }