github.com/webonyx/up@v0.7.4-0.20180808230834-91b94e551323/http/ping/ping.go (about)

     1  // Package ping provides the /_ping no-op route.
     2  package ping
     3  
     4  import (
     5  	"fmt"
     6  	"net/http"
     7  	"time"
     8  
     9  	"github.com/apex/up"
    10  )
    11  
    12  // New ping handler.
    13  func New(c *up.Config, next http.Handler) http.Handler {
    14  	return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
    15  		if r.URL.Path == "/_ping" {
    16  			time.Sleep(time.Second)
    17  			fmt.Fprintln(w, ":)")
    18  			return
    19  		}
    20  
    21  		next.ServeHTTP(w, r)
    22  	})
    23  }