mitchell852 closed pull request #2310: Add TO Go cdns/metric_types route 501 URL: https://github.com/apache/incubator-trafficcontrol/pull/2310
This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): diff --git a/docs/source/api/v11/cdn.rst b/docs/source/api/v11/cdn.rst index d2f742e42..91c926cc1 100644 --- a/docs/source/api/v11/cdn.rst +++ b/docs/source/api/v11/cdn.rst @@ -384,6 +384,8 @@ Metrics **GET /api/1.1/cdns/metric_types/:metric/start_date/:start/end_date/:end** +*Note: this route is not currently implemented in Traffic Ops. See https://github.com/apache/incubator-trafficcontrol/issues/2309* + Retrieves edge metrics of one or all locations (cache groups). Authentication Required: Yes diff --git a/docs/source/api/v12/cdn.rst b/docs/source/api/v12/cdn.rst index 650b0a97a..7cdf9b084 100644 --- a/docs/source/api/v12/cdn.rst +++ b/docs/source/api/v12/cdn.rst @@ -639,8 +639,11 @@ Routing Metrics +++++++ + **GET /api/1.2/cdns/metric_types/:metric/start_date/:start/end_date/:end** +*Note: this route is not currently implemented in Traffic Ops. See https://github.com/apache/incubator-trafficcontrol/issues/2309* + Retrieves edge metrics of one or all locations (cache groups). Authentication Required: Yes diff --git a/traffic_ops/traffic_ops_golang/routes.go b/traffic_ops/traffic_ops_golang/routes.go index 8858c327c..25dcee32b 100644 --- a/traffic_ops/traffic_ops_golang/routes.go +++ b/traffic_ops/traffic_ops_golang/routes.go @@ -95,6 +95,7 @@ func Routes(d ServerData) ([]Route, []RawRoute, http.Handler, error) { {1.1, http.MethodDelete, `cachegroups/{id}$`, api.DeleteHandler(cachegroup.GetRefType(), d.DB), auth.PrivLevelOperations, Authenticated, nil}, //CDN + {1.1, http.MethodGet, `cdns/metric_types`, notImplementedHandler, 0, NoAuth, nil}, // MUST NOT end in $, because the 1.x route is longer {1.1, http.MethodGet, `cdns/capacity$`, handlerToFunc(proxyHandler), 0, NoAuth, []Middleware{}}, {1.1, http.MethodGet, `cdns/configs$`, handlerToFunc(proxyHandler), 0, NoAuth, []Middleware{}}, {1.1, http.MethodGet, `cdns/domains$`, handlerToFunc(proxyHandler), 0, NoAuth, []Middleware{}}, @@ -316,6 +317,13 @@ func rootHandler(d ServerData) http.Handler { return managerHandler } +// 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. +func notImplementedHandler(w http.ResponseWriter, r *http.Request) { + code := http.StatusNotImplemented + w.WriteHeader(code) + w.Write([]byte(http.StatusText(code))) +} + //CreateThrottledHandler takes a handler, and a max and uses a channel to insure the handler is used concurrently by only max number of routines func CreateThrottledHandler(handler http.Handler, maxConcurrentCalls int) ThrottledHandler { return ThrottledHandler{handler, make(chan struct{}, maxConcurrentCalls)} ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services