Created
December 27, 2016 02:07
-
-
Save xiaoping378/9c449f29166e37fa316571d6c6107055 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 ( | |
"fmt" | |
"io/ioutil" | |
"log" | |
"net/http" | |
) | |
func printPost(rw http.ResponseWriter, req *http.Request) { | |
body, err := ioutil.ReadAll(req.Body) | |
req.Body.Close() | |
if err != nil { | |
log.Fatal("ReadAll: ", err) | |
} | |
fmt.Println(string(body)) | |
} | |
func main() { | |
http.HandleFunc("/alerts", printPost) | |
if err := http.ListenAndServe(":4000", nil); err != nil { | |
log.Fatal("ListenAndServe: ", err) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment