You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
720 B

package main
import (
metrics_num_urls int
func main() {
log.Println("Starting HTTP listener")
http.HandleFunc("/", httpHandler)
http.HandleFunc("/metrics", metricsHandler)
listenErr := http.ListenAndServe(":80", nil) // set listen port
if listenErr != nil {
// Handling incoming HTTP connections
func httpHandler(w http.ResponseWriter, r *http.Request) {
log.Printf("(%s) %s %s", r.Method, r.RemoteAddr, r.URL.Path)
// Handle HTTP /metrics requests
func metricsHandler(w http.ResponseWriter, req *http.Request) {
fmt.Fprintf(w, "num_urls %d\n", metrics_num_urls)