mixed handler for both grpc and traditional http
(grpcServer *grpc.Server, httpHandler http.Handler)
| 709 | |
| 710 | // mixed handler for both grpc and traditional http |
| 711 | func mixedHandler(grpcServer *grpc.Server, httpHandler http.Handler) http.Handler { |
| 712 | return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
| 713 | if grpcServer != nil && r.ProtoMajor == 2 && strings.Contains(r.Header.Get(utils.HTTPContentTypeHeaderKey), utils.HTTPContentTypeApplicationGRPC) { |
| 714 | grpcServer.ServeHTTP(w, r) |
| 715 | } else { |
| 716 | httpHandler.ServeHTTP(w, r) |
| 717 | } |
| 718 | }) |
| 719 | } |