Skip to content

Instantly share code, notes, and snippets.

@perigee
Created March 20, 2017 23:07
Show Gist options
  • Save perigee/4f479499a59d3563b51cfa007e59d2b1 to your computer and use it in GitHub Desktop.
Save perigee/4f479499a59d3563b51cfa007e59d2b1 to your computer and use it in GitHub Desktop.

Revisions

  1. perigee created this gist Mar 20, 2017.
    34 changes: 34 additions & 0 deletions server.go
    Original 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))

    }