Skip to content
Snippets Groups Projects
Commit f59989ea authored by Andrei Mihu's avatar Andrei Mihu
Browse files

Set gateway timeout to match idle timeout value.

parent ee0649a1
Branches
Tags
No related merge requests found
......@@ -4,6 +4,8 @@ All notable changes to this project are documented below.
The format is based on [keep a changelog](http://keepachangelog.com) and this project uses [semantic versioning](http://semver.org).
## [Unreleased]
### Fixed
- Set gateway timeout to match idle timeout value.
## [2.3.1] - 2019-01-04
### Added
......
......@@ -77,6 +77,8 @@ type ApiServer struct {
}
func StartApiServer(logger *zap.Logger, startupLogger *zap.Logger, db *sql.DB, jsonpbMarshaler *jsonpb.Marshaler, jsonpbUnmarshaler *jsonpb.Unmarshaler, config Config, socialClient *social.Client, leaderboardCache LeaderboardCache, leaderboardRankCache LeaderboardRankCache, sessionRegistry *SessionRegistry, matchRegistry MatchRegistry, matchmaker Matchmaker, tracker Tracker, router MessageRouter, pipeline *Pipeline, runtime *Runtime) *ApiServer {
grpcRuntime.DefaultContextTimeout = time.Duration(config.GetSocket().IdleTimeoutMs) * time.Millisecond
serverOpts := []grpc.ServerOption{
grpc.StatsHandler(&ocgrpc.ServerHandler{IsPublicEndpoint: true}),
grpc.MaxRecvMsgSize(int(config.GetSocket().MaxMessageSizeBytes)),
......@@ -183,7 +185,15 @@ func StartApiServer(logger *zap.Logger, startupLogger *zap.Logger, db *sql.DB, j
r.Body = http.MaxBytesReader(w, r.Body, maxMessageSizeBytes)
handlerWithCompressResponse.ServeHTTP(w, r)
})
grpcGatewayRouter.NewRoute().Handler(handlerWithMaxBody)
grpcGatewayRouter.NewRoute().HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
// Do not allow clients to set certain headers.
// Currently disallowed headers:
// "Grpc-Timeout"
r.Header.Del("Grpc-Timeout")
// Allow GRPC Gateway to handle the request.
handlerWithMaxBody.ServeHTTP(w, r)
})
// Enable CORS on all requests.
CORSHeaders := handlers.AllowedHeaders([]string{"Authorization", "Content-Type", "User-Agent"})
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment