Skip to content

Instantly share code, notes, and snippets.

@apokalyptik
Created September 16, 2014 17:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save apokalyptik/82741f4ed01264290e40 to your computer and use it in GitHub Desktop.
Save apokalyptik/82741f4ed01264290e40 to your computer and use it in GitHub Desktop.
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