Skip to content

Commit

Permalink
mapping the paylod object
Browse files Browse the repository at this point in the history
  • Loading branch information
kneerunjun committed Mar 22, 2024
1 parent 7ff90ec commit e1739a2
Showing 1 changed file with 25 additions and 4 deletions.
29 changes: 25 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,29 @@ import (
"github.com/gin-gonic/gin"
)

type ReleaseInfo struct {
Body string `json:"body"`
CreatedAt string `json:"created_at"`
Draft bool `json:"draft"`
PreRelease bool `json:"prerelease"`
Tag string `json:"tag_name"`
}
type RepoInfo struct {
Name string `json:"name"`
CloneUrl string `json:"clone_url"`
DefaultBranch string `json:"default_branch"`
}

type SenderInfo struct {
}

type WebHkRelease struct { // payload we receive from web hook notification
Action string `json:"action"`
Release ReleaseInfo `json:"release"`
Repository RepoInfo `json:"repository"`
Sender SenderInfo `json:"sender"`
}

func CORS(c *gin.Context) {
// First, we add the headers with need to enable CORS
// Make sure to adjust these headers to your needs
Expand Down Expand Up @@ -41,7 +64,7 @@ func main() {
c.AbortWithStatus(http.StatusBadRequest)
return
}
res := map[string]interface{}{}
res := WebHkRelease{}
err = json.Unmarshal(byt, &res)
if err != nil {
fmt.Println("Error unmarshaling the payload")
Expand All @@ -50,9 +73,7 @@ func main() {
return
}
fmt.Println("received payload from github..")
for k, v := range res {
fmt.Printf("%s:%v\n", k, v)
}
fmt.Println(res)
c.AbortWithStatus(http.StatusOK)
})
r.Run(":8082")
Expand Down

0 comments on commit e1739a2

Please sign in to comment.