Created
September 16, 2014 17:22
-
-
Save apokalyptik/82741f4ed01264290e40 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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