Skip to content

Commit

Permalink
PaymentでCORSをやめる
Browse files Browse the repository at this point in the history
  • Loading branch information
notchi590 committed Oct 5, 2019
1 parent bb9992d commit 994793b
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions blackbox/payment/server/gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import (
"net/http"
_ "net/http/pprof"

"github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/gorilla/handlers"
"payment/config"
pb "payment/pb"

"github.com/grpc-ecosystem/grpc-gateway/runtime"
"google.golang.org/grpc"
)

Expand All @@ -17,11 +17,6 @@ func newGateway(c config.Config, ctx context.Context, opts ...runtime.ServeMuxOp
runtime.WithMarshalerOption(runtime.MIMEWildcard, &runtime.JSONPb{OrigName: true, EmitDefaults: true}),
}
mux := runtime.NewServeMux(opts...)
newMux := handlers.CORS(
handlers.AllowedMethods([]string{"GET", "POST", "OPTIONS", "PUT", "DELETE"}),
handlers.AllowedOrigins([]string{"*"}),
handlers.AllowedHeaders([]string{"*"}),
)(mux)
dialOpts := []grpc.DialOption{grpc.WithInsecure()}
conn, err := grpc.Dial(c.GrpcPort, dialOpts...)
if err != nil {
Expand All @@ -32,7 +27,7 @@ func newGateway(c config.Config, ctx context.Context, opts ...runtime.ServeMuxOp
return nil, err
}

return newMux, nil
return mux, nil
}

func StartGRPCGateway(c config.Config, opts ...runtime.ServeMuxOption) error {
Expand Down

0 comments on commit 994793b

Please sign in to comment.