srijeet0406 commented on code in PR #6754:
URL: https://github.com/apache/trafficcontrol/pull/6754#discussion_r860047944
##########
traffic_ops/traffic_ops_golang/routing/routing.go:
##########
@@ -280,8 +307,88 @@ func Handler(
h.ServeHTTP(w, r)
return
}
+ var backendRouteHandled bool
+ backendConfig := GetBackendConfig()
+ for i, backendRoute := range backendConfig.Routes {
+ if backendRoute.Path == r.URL.Path && backendRoute.Method ==
r.Method {
+ if backendRoute.Opts.Algorithm == "" ||
backendRoute.Opts.Algorithm == "roundrobin" {
+ index := backendRoute.Index %
len(backendRoute.Hosts)
+ host := backendRoute.Hosts[index]
+ backendRoute.Index++
+ backendConfig.Routes[i] = backendRoute
+ backendRouteHandled = true
+ rp :=
httputil.NewSingleHostReverseProxy(&url.URL{
+ Host: host,
+ Scheme: cfg.URL.Scheme,
+ })
+ if backendRoute.Insecure {
+ rp.Transport = &http.Transport{
+ TLSClientConfig:
&tls.Config{InsecureSkipVerify: true},
+ }
+ } else {
+ rp.Transport = &http.Transport{
+ TLSClientConfig: &tls.Config{},
+ }
+ }
+ rp.ErrorHandler = func(w http.ResponseWriter, r
*http.Request, err error) {
+ api.HandleErr(w, r, nil,
http.StatusInternalServerError, nil, err)
+ return
+ }
+ routeCtx := context.WithValue(ctx,
api.DBContextKey, db)
+ routeCtx = context.WithValue(routeCtx,
api.PathParamsKey, map[string]string{})
+ r = r.WithContext(routeCtx)
+ r.Header.Add(middleware.RouteID,
strconv.Itoa(backendRoute.ID))
Review Comment:
Yep, sure can. I've changed it in both the places this was being set as a
header.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]