feat: add enable and disable keep alive
This commit is contained in:
@@ -153,6 +153,7 @@ type Gateway struct {
|
|||||||
//Disable dispelling routes on start
|
//Disable dispelling routes on start
|
||||||
DisableDisplayRouteOnStart bool `yaml:"disableDisplayRouteOnStart"`
|
DisableDisplayRouteOnStart bool `yaml:"disableDisplayRouteOnStart"`
|
||||||
InterceptErrors []int `yaml:"interceptErrors"`
|
InterceptErrors []int `yaml:"interceptErrors"`
|
||||||
|
EnableKeepAlive bool `yaml:"enableKeepAlive"`
|
||||||
// Cors contains the proxy global cors
|
// Cors contains the proxy global cors
|
||||||
Cors Cors `yaml:"cors"`
|
Cors Cors `yaml:"cors"`
|
||||||
// Routes defines the proxy routes
|
// Routes defines the proxy routes
|
||||||
|
|||||||
@@ -57,6 +57,8 @@ func (intercept InterceptErrors) ErrorInterceptor(next http.Handler) http.Handle
|
|||||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
rec := newResponseRecorder(w)
|
rec := newResponseRecorder(w)
|
||||||
next.ServeHTTP(rec, r)
|
next.ServeHTTP(rec, r)
|
||||||
|
//Set Server name
|
||||||
|
w.Header().Set("Server", "Goma")
|
||||||
if canIntercept(rec.statusCode, intercept.Errors) {
|
if canIntercept(rec.statusCode, intercept.Errors) {
|
||||||
logger.Debug("Backend error intercepted")
|
logger.Debug("Backend error intercepted")
|
||||||
logger.Debug("An error occurred in the backend, %d", rec.statusCode)
|
logger.Debug("An error occurred in the backend, %d", rec.statusCode)
|
||||||
|
|||||||
@@ -38,8 +38,6 @@ func (proxyRoute ProxyRoute) ProxyHandler() http.HandlerFunc {
|
|||||||
return func(w http.ResponseWriter, r *http.Request) {
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
realIP := getRealIP(r)
|
realIP := getRealIP(r)
|
||||||
logger.Info("%s %s %s %s", r.Method, realIP, r.URL, r.UserAgent())
|
logger.Info("%s %s %s %s", r.Method, realIP, r.URL, r.UserAgent())
|
||||||
//Set Server name
|
|
||||||
w.Header().Set("Server", serverName)
|
|
||||||
// Set CORS headers from the cors config
|
// Set CORS headers from the cors config
|
||||||
//Update Cors Headers
|
//Update Cors Headers
|
||||||
for k, v := range proxyRoute.cors.Headers {
|
for k, v := range proxyRoute.cors.Headers {
|
||||||
|
|||||||
@@ -39,6 +39,8 @@ func (gatewayServer GatewayServer) Start(ctx context.Context) error {
|
|||||||
if !gatewayServer.gateway.DisableDisplayRouteOnStart {
|
if !gatewayServer.gateway.DisableDisplayRouteOnStart {
|
||||||
printRoute(gatewayServer.gateway.Routes)
|
printRoute(gatewayServer.gateway.Routes)
|
||||||
}
|
}
|
||||||
|
// Set KeepAlive
|
||||||
|
srv.SetKeepAlivesEnabled(gatewayServer.gateway.EnableKeepAlive)
|
||||||
go func() {
|
go func() {
|
||||||
|
|
||||||
logger.Info("Started Goma Gateway server on %v", gatewayServer.gateway.ListenAddr)
|
logger.Info("Started Goma Gateway server on %v", gatewayServer.gateway.ListenAddr)
|
||||||
|
|||||||
Reference in New Issue
Block a user