Created
August 7, 2017 09:02
-
-
Save syguer/a182babd8b6d52f291ea6d2dfc5b3e75 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 ( | |
| "net/http" | |
| "io/ioutil" | |
| "encoding/json" | |
| "log" | |
| "strconv" | |
| "fmt" | |
| ) | |
| type HookReleaseObject struct { | |
| HtmlUrl string `json:"html_url"` | |
| TagName string `json:"tag_name"` | |
| } | |
| type HookObject struct { | |
| Release HookReleaseObject `json:"release"` | |
| } | |
| type Server struct { | |
| Port int | |
| Server *http.Server | |
| } | |
| type Handler struct {} | |
| func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { | |
| fmt.Println(r.Body) | |
| body, _ := ioutil.ReadAll(r.Body) | |
| o := HookObject{} | |
| json.Unmarshal(body, &o) | |
| fmt.Println(o) | |
| } | |
| func (s *Server) start() { | |
| h := Handler{} | |
| http.Handle("/", &h) | |
| s.Server = &http.Server{ | |
| Addr: ":" + strconv.Itoa(s.Port), | |
| Handler: &h, | |
| } | |
| log.Fatal(s.Server.ListenAndServe()) | |
| } | |
| func main() { | |
| s := Server{Port: 8080} | |
| s.start() | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment