readnotes/devops/prometheus/source_code/main.go

24 lines
414 B
Go
Raw Normal View History

2022-01-17 11:41:03 +08:00
package main
import (
"log"
"net/http"
"github.com/prometheus/client_golang/prometheus/promhttp"
)
func runHTTPServer()error{
http.Handle("/metrics", promhttp.Handler())
http.HandleFunc("/", func (w http.ResponseWriter, r *http.Request){
w.Write([]byte("hello world!"))
})
return http.ListenAndServe("localhost:8080", nil)
}
func main(){
err := runHTTPServer()
if err != nil {
log.Fatal(err)
}
}