initial commit

This commit is contained in:
ston1th 2018-12-24 14:59:39 +01:00
commit 68e8ab190e
6 changed files with 162 additions and 0 deletions

30
db.go Normal file
View file

@ -0,0 +1,30 @@
package main
import (
"fmt"
"log"
"net/http"
"os"
"time"
)
var version string
func main() {
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
log.Printf("%s %s %s", r.RemoteAddr, r.Method, r.URL)
h, err := os.Hostname()
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
fmt.Fprintf(w, "%s (%s)\n", h, version)
})
s := &http.Server{
ReadTimeout: 5 * time.Second,
WriteTimeout: 10 * time.Second,
IdleTimeout: 120 * time.Second,
Addr: ":8080",
}
log.Fatal(s.ListenAndServe())
}