Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
package main
import (
"flag"
"fmt"
"log"
"net/http"
)
var listenOn = "127.0.0.1:8888"
func helloHandler(w http.ResponseWriter, r *http.Request) {
log.Printf("%#v", r)
fmt.Fprint(w, "hello world")
}
func init() {
flag.StringVar(&listenOn, "listen", listenOn, "The address to listen on for web requests")
}
func main() {
flag.Parse()
http.HandleFunc("/hello", helloHandler)
log.Fatal(http.ListenAndServe(listenOn, nil))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.