1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-20 03:17:04 +00:00

add a full gRPC example as previously requested at: https://github.com/kataras/iris/issues/1449

Former-commit-id: 0cb5121e7d44644f7f0eb34597ff34274157fe95
This commit is contained in:
Gerasimos (Makis) Maropoulos
2020-03-07 12:53:23 +02:00
parent dd18dc9ee8
commit aea836efc7
11 changed files with 414 additions and 24 deletions

View File

@@ -20,11 +20,11 @@ import (
// app.WrapRouter(grpcWrapper.New(grpcServer))
func New(grpcServer http.Handler) router.WrapperFunc {
return func(w http.ResponseWriter, r *http.Request, mux http.HandlerFunc) {
if r.ProtoMajor == 2 && strings.HasPrefix(
r.Header.Get("Content-Type"), "application/grpc") {
if r.ProtoMajor == 2 && strings.HasPrefix(r.Header.Get("Content-Type"), "application/grpc") {
grpcServer.ServeHTTP(w, r)
} else {
mux.ServeHTTP(w, r)
return
}
mux.ServeHTTP(w, r)
}
}