package main
import (
"log"
"net/http"
)
func main() {
http.HandleFunc("/hello", helloHandler)
http.HandleFunc("/bad", badHandler)
http.HandleFunc("/good", goodHandler)
err := http.ListenAndServe(":8080", nil)
log.Fatal(err)
}
func helloHandler(writer http.ResponseWriter, request *http.Request) {
write(writer, "Hello")
}
func badHandler(writer http.ResponseWriter, request *http.Request) {
write(writer, "Bad")
}
func goodHandler(writer http.ResponseWriter, request *http.Request) {
write(writer, "Good")
}
func write(writer http.ResponseWriter, str string) {
_, err := writer.Write([]byte(str))
if err != nil {
log.Fatal(err)
}
}