Use map to check for long-running request

Signed-off-by: Ted Yu <yute@vmware.com>
This commit is contained in:
Ted Yu 2019-04-30 19:32:33 -07:00 committed by Ted Yu
parent 16085784bc
commit fe6e50df3d

View File

@ -824,15 +824,17 @@ func trimURLPath(path string) string {
return parts[0]
}
var longRunningRequestPathMap = map[string]bool{
"exec": true,
"attach": true,
"portforward": true,
"debug": true,
}
// isLongRunningRequest determines whether the request is long-running or not.
func isLongRunningRequest(path string) bool {
longRunningRequestPaths := []string{"exec", "attach", "portforward", "debug"}
for _, p := range longRunningRequestPaths {
if p == path {
return true
}
}
return false
_, ok := longRunningRequestPathMap[path]
return ok
}
// ServeHTTP responds to HTTP requests on the Kubelet.