28 lines
517 B
Go
28 lines
517 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"net/http"
|
|
|
|
log "github.com/sirupsen/logrus"
|
|
)
|
|
|
|
func main() {
|
|
http.HandleFunc("/", helloWorldHandler)
|
|
port := 9000
|
|
|
|
log.Info("Starting on port ", port)
|
|
|
|
err := http.ListenAndServe(fmt.Sprint(":", port), nil)
|
|
if err != nil {
|
|
log.Error("Something bad happened")
|
|
}
|
|
}
|
|
|
|
func helloWorldHandler(w http.ResponseWriter, r *http.Request) {
|
|
log.Info("Request from", r.RemoteAddr)
|
|
_, err := w.Write([]byte("Hello World"))
|
|
if err != nil {
|
|
log.Error("Unable to write hello world")
|
|
}
|
|
}
|