soheilhy / cmux

Connection multiplexer for GoLang: serve different services on the same port!
Apache License 2.0
2.53k stars 197 forks source link

Cmux example #88

Closed delwaterman closed 2 years ago

delwaterman commented 2 years ago

You're example has a tiny bug, which tripped me up for a few days. You're matchers are case sensitive. So

// Match connections in order:
// First grpc, then HTTP, and otherwise Go RPC/TCP.
- grpcL := m.Match(cmux.HTTP2HeaderField("content-type", "application/grpc"))
+ grpcL := m.Match(cmux.HTTP2HeaderField("Content-type", "application/grpc"))
httpL := m.Match(cmux.HTTP1Fast())
trpcL := m.Match(cmux.Any()) // Any means anything that is not yet matched.
delwaterman commented 2 years ago

I was incorrect, there is another issue, which I am trying to hunt down now.