//
// Copyright 2016 Gregory Trubetskoy. All Rights Reserved.
//
// Licensed 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.

package daemon

import (
	"fmt"
	h "github.com/tgres/tgres/http"
	x "github.com/tgres/tgres/transceiver"
	"net"
	"net/http"
	"time"
)

func httpServer(addr string, l net.Listener, t *x.Transceiver) {

	http.HandleFunc("/metrics/find", h.GraphiteMetricsFindHandler(t))
	http.HandleFunc("/render", h.GraphiteRenderHandler(t))
	http.HandleFunc("/ping", func(w http.ResponseWriter, r *http.Request) { fmt.Fprintf(w, "OK\n") })

	server := &http.Server{
		Addr:           addr,
		ReadTimeout:    10 * time.Second,
		WriteTimeout:   10 * time.Second,
		MaxHeaderBytes: 1 << 16}
	server.Serve(l)
}

//
// Copyright 2016 Gregory Trubetskoy. All Rights Reserved.
//
// Licensed 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.

package daemon

import (
	h "github.com/tgres/tgres/http"
	x "github.com/tgres/tgres/transceiver"
	"net"
	"net/http"
	"time"
)

func httpServer(addr string, l net.Listener, t *x.Transceiver) {

	http.HandleFunc("/metrics/find", h.GraphiteMetricsFindHandler(t))
	http.HandleFunc("/render", h.GraphiteRenderHandler(t))

	server := &http.Server{
		Addr:           addr,
		ReadTimeout:    10 * time.Second,
		WriteTimeout:   10 * time.Second,
		MaxHeaderBytes: 1 << 16}
	server.Serve(l)
}

--- 
+++ 
@@ -16,6 +16,7 @@
 package daemon
 
 import (
+	"fmt"
 	h "github.com/tgres/tgres/http"
 	x "github.com/tgres/tgres/transceiver"
 	"net"
@@ -27,6 +28,7 @@
 
 	http.HandleFunc("/metrics/find", h.GraphiteMetricsFindHandler(t))
 	http.HandleFunc("/render", h.GraphiteRenderHandler(t))
+	http.HandleFunc("/ping", func(w http.ResponseWriter, r *http.Request) { fmt.Fprintf(w, "OK\n") })
 
 	server := &http.Server{
 		Addr:           addr,
Add a /ping URL for the load balancer
