Created
February 11, 2018 22:06
-
-
Save rodesousa/d1570d03d4adf791fcd16a3bb23daafe to your computer and use it in GitHub Desktop.
simply_handler #golang
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 ( | |
| "fmt" | |
| "io/ioutil" | |
| "net/http" | |
| ) | |
| func handler(w http.ResponseWriter, r *http.Request) { | |
| fmt.Fprintf(w, "Hi there, I love %s!", r.URL.Path[1:]) | |
| body, _ := ioutil.ReadAll(r.Body) | |
| fmt.Println(string(body)) | |
| } | |
| func main() { | |
| http.HandleFunc("/", handler) | |
| http.ListenAndServe(":8080", nil) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment