Skip to content

Commit

Permalink
Document Server.ServeHTTP (#1406)
Browse files Browse the repository at this point in the history
Fixes #549
  • Loading branch information
bradfitz authored and dfawley committed Aug 7, 2017
1 parent 059280c commit 383b114
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,29 @@ func (s *Server) serveUsingHandler(conn net.Conn) {
})
}

// ServeHTTP implements the Go standard library's http.Handler
// interface by responding to the gRPC request r, by looking up
// the requested gRPC method in the gRPC server s.
//
// The provided HTTP request must have arrived on an HTTP/2
// connection. When using the Go standard library's server,
// practically this means that the Request must also have arrived
// over TLS.
//
// To share one port (such as 443 for https) between gRPC and an
// existing http.Handler, use a root http.Handler such as:
//
// if r.ProtoMajor == 2 && strings.HasPrefix(
// r.Header.Get("Content-Type"), "application/grpc") {
// grpcServer.ServeHTTP(w, r)
// } else {
// yourMux.ServeHTTP(w, r)
// }
//
// Note that ServeHTTP uses Go's HTTP/2 server implementation which is
// totally separate from grpc-go's HTTP/2 server. Performance and
// features may vary between the two paths. ServeHTTP may not respect
// all provided grpc.ServerOption values.
func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
st, err := transport.NewServerHandlerTransport(w, r)
if err != nil {
Expand Down

0 comments on commit 383b114

Please sign in to comment.