Last active
July 18, 2019 16:12
-
-
Save nleiva/afb6264fea980176305c3026217c58b4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func grpcHandlerFunc(g *grpc.Server, h http.Handler) http.Handler { | |
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { | |
ct := r.Header.Get("Content-Type") | |
if r.ProtoMajor == 2 && strings.Contains(ct, "application/grpc") { | |
g.ServeHTTP(w, r) | |
} else { | |
h.ServeHTTP(w, r) | |
} | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment