Skip to content

Commit

Permalink
GITBOOK-239: No subject
Browse files Browse the repository at this point in the history
  • Loading branch information
mouuii authored and gitbook-bot committed Jan 17, 2025
1 parent 220c911 commit 3080249
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -670,9 +670,9 @@ func (s *APIAggregator) AddAPIService(apiService *v1.APIService) error {

`/apis/<group>/<version>`开头的请求的最终是由`proxyHandler.ServeHTTP()`来处理,代码如下:

<pre class="language-go"><code class="lang-go"><strong>// staging\src\k8s.io\kube-aggregator\pkg\apiserver\handler_proxy.go
</strong><strong>func (r *proxyHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
</strong> value := r.handlingInfo.Load()
```go
func (r *proxyHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
value := r.handlingInfo.Load()
if value == nil {
r.localDelegate.ServeHTTP(w, req)
return
Expand Down Expand Up @@ -704,7 +704,7 @@ func (s *APIAggregator) AddAPIService(apiService *v1.APIService) error {
}

// write a new location based on the existing request pointed at the target service
location := &#x26;url.URL{}
location := &url.URL{}
location.Scheme = "https"
rloc, err := r.serviceResolver.ResolveEndpoint(handlingInfo.serviceNamespace, handlingInfo.serviceName, handlingInfo.servicePort)
if err != nil {
Expand Down Expand Up @@ -734,7 +734,7 @@ func (s *APIAggregator) AddAPIService(apiService *v1.APIService) error {

proxyRoundTripper = transport.NewAuthProxyRoundTripper(user.GetName(), userUID, user.GetGroups(), user.GetExtra(), proxyRoundTripper)

if utilfeature.DefaultFeatureGate.Enabled(genericfeatures.APIServerTracing) &#x26;&#x26; !upgrade {
if utilfeature.DefaultFeatureGate.Enabled(genericfeatures.APIServerTracing) && !upgrade {
tracingWrapper := tracing.WrapperFor(r.tracerProvider)
proxyRoundTripper = tracingWrapper(proxyRoundTripper)
}
Expand All @@ -746,14 +746,14 @@ func (s *APIAggregator) AddAPIService(apiService *v1.APIService) error {
transport.SetAuthProxyHeaders(newReq, user.GetName(), userUID, user.GetGroups(), user.GetExtra())
}

handler := proxy.NewUpgradeAwareHandler(location, proxyRoundTripper, true, upgrade, &#x26;responder{w: w})
handler := proxy.NewUpgradeAwareHandler(location, proxyRoundTripper, true, upgrade, &responder{w: w})
if r.rejectForwardingRedirects {
handler.RejectForwardingRedirects = true
}
utilflowcontrol.RequestDelegated(req.Context())
handler.ServeHTTP(w, newReq)
}
</code></pre>
```

### PrepareRun

Expand Down

0 comments on commit 3080249

Please sign in to comment.