Skip to content

Commit

Permalink
/ hostname
Browse files Browse the repository at this point in the history
  • Loading branch information
portertech committed Feb 7, 2018
1 parent 881ca88 commit 9222d77
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"log"
"net/http"
"os"
"time"

"github.com/gorilla/mux"
Expand All @@ -14,7 +15,16 @@ var healthy = true
func main() {
r := mux.NewRouter()

r.Handle("/", http.FileServer(http.Dir("/www")))
r.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
hostname, err := os.Hostname()

if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
} else {
w.Write([]byte(hostname))
}
}).Methods(http.MethodGet)

r.HandleFunc("/healthz", func(w http.ResponseWriter, r *http.Request) {
if healthy {
w.Write([]byte("healthy"))
Expand Down

0 comments on commit 9222d77

Please sign in to comment.