This is an automated email from the ASF dual-hosted git repository.

dewrich pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-trafficcontrol.git

commit 85adf6d0af5c33af787d3fe296e8e036f2dbb720
Author: Dan Kirkwood <dang...@apache.org>
AuthorDate: Mon Mar 5 16:39:19 2018 -0700

    adds ping route
---
 traffic_ops/traffic_ops_golang/ping.go   | 34 ++++++++++++++++++++++++++++++++
 traffic_ops/traffic_ops_golang/routes.go |  4 ++++
 2 files changed, 38 insertions(+)

diff --git a/traffic_ops/traffic_ops_golang/ping.go 
b/traffic_ops/traffic_ops_golang/ping.go
new file mode 100644
index 0000000..a7377dd
--- /dev/null
+++ b/traffic_ops/traffic_ops_golang/ping.go
@@ -0,0 +1,34 @@
+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 (
+       "encoding/json"
+       "net/http"
+)
+
+// pingHandler simply returns a canned response to show that the server is 
responding
+func pingHandler() http.HandlerFunc {
+       return func(w http.ResponseWriter, r *http.Request) {
+               m := map[string]string{"ping": "pong"}
+               enc := json.NewEncoder(w)
+               enc.Encode(m)
+       }
+}
diff --git a/traffic_ops/traffic_ops_golang/routes.go 
b/traffic_ops/traffic_ops_golang/routes.go
index 2bb388f..ba9a34b 100644
--- a/traffic_ops/traffic_ops_golang/routes.go
+++ b/traffic_ops/traffic_ops_golang/routes.go
@@ -141,6 +141,10 @@ func Routes(d ServerData) ([]Route, http.Handler, error) {
                //Parameters
                {1.3, http.MethodGet, `parameters/?(\.json)?$`, 
parametersHandler(d.DB), auth.PrivLevelReadOnly, Authenticated, nil},
 
+               //Ping
+               {1.2, http.MethodGet, `ping$`, pingHandler(), 
auth.PrivLevelReadOnly, Authenticated, nil},
+
+               //Servers
                {1.2, http.MethodGet, `servers/?(\.json)?$`, 
serversHandler(d.DB), auth.PrivLevelReadOnly, Authenticated, nil},
                {1.2, http.MethodGet, `servers/{id}$`, serversHandler(d.DB), 
auth.PrivLevelReadOnly, Authenticated, nil},
                {1.2, http.MethodPost, `servers/{id}/deliveryservices$`, 
assignDeliveryServicesToServerHandler(d.DB), auth.PrivLevelOperations, 
Authenticated, nil},

-- 
To stop receiving notification emails like this one, please contact
dewr...@apache.org.

Reply via email to