Created
March 20, 2017 23:07
-
-
Save perigee/4f479499a59d3563b51cfa007e59d2b1 to your computer and use it in GitHub Desktop.
Revisions
-
perigee created this gist
Mar 20, 2017 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,34 @@ package main import ( "encoding/json" "log" "net/http" "flag" "github.com/golang/glog" "github.com/gorilla/mux" ) type Sample struct { Output string `json:"output"` } func CreateResult(w http.ResponseWriter, req *http.Request) { var s Sample _ = json.NewDecoder(req.Body).Decode(&s) glog.Infof("receive: %v", s.Output) } func main() { flag.Parse() //logger := log.New(os.Stdout, "terraform: ", log.Lshortfile|log.LstdFlags) router := mux.NewRouter() router.HandleFunc("/result", CreateResult).Methods("PUT") log.Fatal(http.ListenAndServe(":8089", router)) }