Github user alficles commented on a diff in the pull request:

    
https://github.com/apache/incubator-trafficcontrol/pull/729#discussion_r129994857
  
    --- Diff: traffic_ops/traffic_ops_golang/routes.go ---
    @@ -0,0 +1,125 @@
    +package main
    +
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements.  See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership.  The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + * with the License.  You may obtain a copy of the License at
    + *
    + *   http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing,
    + * software distributed under the License is distributed on an
    + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    + * KIND, either express or implied.  See the License for the
    + * specific language governing permissions and limitations
    + * under the License.
    + */
    +
    +import (
    +   "crypto/tls"
    +   "database/sql"
    +   "fmt"
    +   "net/http"
    +   "net/http/httputil"
    +   "regexp"
    +   "strings"
    +)
    +
    +type ServerData struct {
    +   Config
    +   DB *sql.DB
    +}
    +
    +type ParamMap map[string]string
    +
    +type RegexHandlerFunc func(w http.ResponseWriter, r *http.Request, params 
ParamMap)
    +
    +// getRootHandler returns the / handler for the service, which 
reverse-proxies the old Perl Traffic Ops
    +func getRootHandler(d ServerData) http.Handler {
    +   // debug
    +   tr := &http.Transport{
    +           TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
    +   }
    +   rp := httputil.NewSingleHostReverseProxy(d.TOURL)
    +   rp.Transport = tr
    +
    +   loggingProxyHandler := wrapAccessLog(d.TOSecret, rp)
    +   return loggingProxyHandler
    +}
    +
    +// GetRoutes returns the map of regex routes, and a catchall route for 
when no regex matches.
    +func GetRoutes(d ServerData) (map[string]RegexHandlerFunc, http.Handler, 
error) {
    +   privLevelStmt, err := preparePrivLevelStmt(d.DB)
    +   if err != nil {
    +           return nil, nil, fmt.Errorf("Error preparing db priv level 
query: ", err)
    +   }
    +
    +   return map[string]RegexHandlerFunc{
    +           "api/1.2/cdns/{cdn}/configs/monitoring":      
wrapHeaders(wrapAuth(monitoringHandler(d.DB), d.Insecure, d.TOSecret, 
privLevelStmt, MonitoringPrivLevel)),
    --- End diff --
    
    It's a good point. If you start getting a lot of them, it might get a bit 
tricky. I'm not sure I see a simple way around it. It already uses wrapper 
functions to efficiently put the required data all together. Do you have a 
better suggestion for a way to write it more clearly?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to