Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
54ced08b5a
|
||
|
|
19adf9cb94
|
@@ -2,18 +2,20 @@ package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
)
|
||||
|
||||
const version = "v0.0.7"
|
||||
|
||||
type v struct {
|
||||
Hostname string `json:"hostname"`
|
||||
V string `json:"version"`
|
||||
}
|
||||
|
||||
func main() {
|
||||
panic("a bug")
|
||||
hn, err := os.Hostname()
|
||||
if err != nil {
|
||||
log.Fatalf("hostname: %+v", err)
|
||||
@@ -22,12 +24,17 @@ func main() {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
r := v{
|
||||
Hostname: hn,
|
||||
V: "v0.0.4",
|
||||
V: version,
|
||||
}
|
||||
if err := json.NewEncoder(w).Encode(r); err != nil {
|
||||
log.Printf("json: %+v", err)
|
||||
}
|
||||
})
|
||||
http.HandleFunc("/env", func(w http.ResponseWriter, req *http.Request) {
|
||||
for _, line := range os.Environ() {
|
||||
fmt.Fprintf(w, "%v\n", line)
|
||||
}
|
||||
})
|
||||
if err := http.ListenAndServe(":8080", nil); err != nil {
|
||||
log.Fatalf("listen and serve: %v", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user