df1d7acb04
address
31 lines
670 B
Go
31 lines
670 B
Go
package server
|
|
|
|
import (
|
|
"flag"
|
|
"golang.org/x/net/context"
|
|
"github.com/grpc-ecosystem/grpc-gateway/runtime"
|
|
"google.golang.org/grpc"
|
|
pb "git.loafle.net/overflow/overflow_api_service/grpc"
|
|
"net/http"
|
|
)
|
|
|
|
var (
|
|
overflowEndpoint = flag.String("echo_endpoint", "localhost:9090", "/v1/overflow/services")
|
|
)
|
|
|
|
func RunGwRpc() (err error) {
|
|
ctx := context.Background()
|
|
ctx, cancel := context.WithCancel(ctx)
|
|
defer cancel()
|
|
|
|
mux := runtime.NewServeMux()
|
|
opts := []grpc.DialOption{grpc.WithInsecure()}
|
|
|
|
err = pb.RegisterOverflowGatewayHandlerFromEndpoint(ctx, mux, *overflowEndpoint, opts)
|
|
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
return http.ListenAndServe(":8080", mux)
|
|
} |