rimashah25 commented on a change in pull request #5209:
URL: https://github.com/apache/trafficcontrol/pull/5209#discussion_r575540359
##########
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:
Is this function (notImplementedHandler) required? since it was
primarily used for Perl routes?
----------------------------------------------------------------
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]