ocket8888 commented on a change in pull request #5209:
URL: https://github.com/apache/trafficcontrol/pull/5209#discussion_r576378718
##########
File path: traffic_ops/traffic_ops_golang/routing/routes.go
##########
@@ -1826,32 +1804,18 @@ func DBStatsHandler(db *sqlx.DB) http.HandlerFunc {
}
}
-// RootHandler returns the / handler for the service, which reverse-proxies
the old Perl Traffic Ops
-func rootHandler(d ServerData) http.Handler {
- tr := &http.Transport{
- TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
- DialContext: (&net.Dialer{
- Timeout: time.Duration(d.Config.ProxyTimeout) *
time.Second,
- KeepAlive: time.Duration(d.Config.ProxyKeepAlive) *
time.Second,
- }).DialContext,
- TLSHandshakeTimeout: time.Duration(d.Config.ProxyTLSTimeout)
* time.Second,
- ResponseHeaderTimeout:
time.Duration(d.Config.ProxyReadHeaderTimeout) * time.Second,
- //IdleConnTimeout: time.Duration(d.Config.ProxyIdleConnTimeout)
* time.Second,
- //Other knobs we can turn: ExpectContinueTimeout,IdleConnTimeout
- }
- rp := httputil.NewSingleHostReverseProxy(d.URL)
- rp.Transport = tr
-
- rp.ErrorLog = log.StandardLogger(log.Error, "proxy error: ")
- riak.SetErrorLogger(log.StandardLogger(log.Error, "riak error: "))
- riak.SetLogger(log.StandardLogger(log.Info, "riak info: "))
+type root struct {
+ Handler http.Handler
+}
- log.Debugf("our reverseProxy: %++v\n", rp)
- log.Debugf("our reverseProxy's transport: %++v\n", tr)
- loggingProxyHandler := middleware.WrapAccessLog(d.Secrets[0], rp)
+func (root) ServeHTTP(w http.ResponseWriter, r *http.Request) {
+ alerts := tc.CreateAlerts(tc.ErrorLevel, fmt.Sprintf("The requested
path '%s' does not exist.", r.URL.Path))
+ api.WriteAlerts(w, r, http.StatusNotFound, alerts)
+}
- managerHandler := CreateThrottledHandler(loggingProxyHandler,
d.BackendMaxConnections["mojolicious"])
- return managerHandler
+// rootHandler returns the / handler for the service, which simply returns a
"not found" response.
+func rootHandler(d ServerData) http.Handler {
+ return root{}
}
// notImplementedHandler returns a 501 Not Implemented to the client. This
should be used very rarely, and primarily for old API Perl routes which were
broken long ago, which we don't have the resources to rewrite in Go for the
time being.
Review comment:
Yeah, that's going to need to stick around as long as APIv1 exists. It's
basically used to fill "holes" that the Go implementation has in the v1 API.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]