Skip to content

Instantly share code, notes, and snippets.

@wayneashleyberry
Created August 6, 2018 10:47
Show Gist options
  • Save wayneashleyberry/98f1a67e9330fe81582f51e9bed3d021 to your computer and use it in GitHub Desktop.
Save wayneashleyberry/98f1a67e9330fe81582f51e9bed3d021 to your computer and use it in GitHub Desktop.
The hello world of Go servers (with a health check)
package main
import (
"net/http"
"github.com/go-chi/chi"
"github.com/go-chi/chi/middleware"
)
func main() {
r := chi.NewRouter()
r.Use(middleware.Heartbeat("/health"))
r.Get("/", func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("Hello, World!"))
})
http.ListenAndServe(":3000", r)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment