Created
November 28, 2016 16:17
-
-
Save kaneshin/71dd2a0a086449dccd13279ccdfe9de1 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 ( | |
"log" | |
"net/http" | |
) | |
func EchoHandler(msg string) func(http.ResponseWriter, *http.Request) { | |
return func(w http.ResponseWriter, r *http.Request) { | |
w.Header().Set("Content-Type", "text/plain") | |
w.WriteHeader(http.StatusOK) | |
w.Write([]byte(msg)) | |
} | |
} | |
func init() { | |
http.HandleFunc("/hello", EchoHandler("hello")) | |
} | |
func main() { | |
log.Fatal(http.ListenAndServe(":8080", nil)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment