-
-
Save travisperson/c97cc51f855b32536f7f to your computer and use it in GitHub Desktop.
This file contains 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 ( | |
"github.com/gin-gonic/gin" | |
"fmt" | |
) | |
type GithubUser struct { | |
Name string `json:name` | |
Email string `json:email` | |
Username string `json:username` | |
} | |
type GithubCommit struct { | |
Id string `json:id` | |
Message string `json:message` | |
Author GithubUser `json:author` | |
Committer GithubUser `json:committer` | |
} | |
type EventPush struct { | |
Ref string `json:ref` | |
After string `json:after` | |
Before string `json:before` | |
Created bool `json:created` | |
Deleted bool `json:deleted` | |
Forced bool `json:forced` | |
HeadCommit GithubCommit `json:head_commit` | |
Pusher GithubUser `json:pusher` | |
} | |
func main () { | |
r := gin.Default() | |
r.GET("/", func(c *gin.Context) { | |
c.String(200, "Hello World!") | |
}) | |
r.POST("/", func(c *gin.Context) { | |
event_type := c.Request.Header.Get("X-Github-Event") | |
fmt.Println(event_type) | |
switch event_type { | |
case "push": | |
PostEventHandler(c) | |
default: | |
c.String(500, "Event not implemented") | |
} | |
}) | |
r.Run(":1440") | |
} | |
func PostEventHandler(c *gin.Context) { | |
var event EventPush | |
if c.Bind(&event) { | |
fmt.Println(event) | |
fmt.Printf("ref %s\n", event.Ref) | |
fmt.Printf("after %s\n", event.After) | |
fmt.Printf("before %s\n", event.Before) | |
fmt.Printf("hc:id %s\n", event.HeadCommit.Id) | |
fmt.Printf("hc:auth:name %s\n", event.HeadCommit.Author.Name) | |
} | |
c.String(200, "") | |
} |
This file contains 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
{ | |
"ref": "refs/heads/master", | |
"after": "19c7b1cfdd021cc20ecd85ef3dd0923c859cac7b", | |
"before": "052a341aae655d77cfe048a4fd9cc1e7c1711999", | |
"created": false, | |
"deleted": false, | |
"forced": false, | |
"compare": "https://github.eecs.wsu.edu/2014-fall-421-423-arslanay/Wookie/compare/052a341aae65...19c7b1cfdd02", | |
"commits": [ | |
{ | |
"id": "b9569ffcc3c64a3cbb886bb314dc779948267ca9", | |
"distinct": true, | |
"message": "Removed the printing to stdout", | |
"timestamp": "2014-09-30T20:19:47Z", | |
"url": "https://github.eecs.wsu.edu/2014-fall-421-423-arslanay/Wookie/commit/b9569ffcc3c64a3cbb886bb314dc779948267ca9", | |
"author": { | |
"name": "Travis Person", | |
"email": "travis.person@gmail.com", | |
"username": "tperson" | |
}, | |
"committer": { | |
"name": "Travis Person", | |
"email": "travis.person@gmail.com", | |
"username": "tperson" | |
}, | |
"added": [ | |
], | |
"removed": [ | |
], | |
"modified": [ | |
"test/clients.py" | |
] | |
}, | |
{ | |
"id": "d22e538ff2ef87327c7e367961e37b9731861637", | |
"distinct": true, | |
"message": "modified tests to check for over zero with multi block files.", | |
"timestamp": "2014-09-30T13:53:47-07:00", | |
"url": "https://github.eecs.wsu.edu/2014-fall-421-423-arslanay/Wookie/commit/d22e538ff2ef87327c7e367961e37b9731861637", | |
"author": { | |
"name": "Raeanne Marks", | |
"email": "raeanne.marks@gmail.com", | |
"username": "rmarks" | |
}, | |
"committer": { | |
"name": "Raeanne Marks", | |
"email": "raeanne.marks@gmail.com", | |
"username": "rmarks" | |
}, | |
"added": [ | |
], | |
"removed": [ | |
], | |
"modified": [ | |
"test/FileGenerator.py" | |
] | |
}, | |
{ | |
"id": "19c7b1cfdd021cc20ecd85ef3dd0923c859cac7b", | |
"distinct": true, | |
"message": "added a check to get correct amount of bytes from rand", | |
"timestamp": "2014-09-30T14:00:56-07:00", | |
"url": "https://github.eecs.wsu.edu/2014-fall-421-423-arslanay/Wookie/commit/19c7b1cfdd021cc20ecd85ef3dd0923c859cac7b", | |
"author": { | |
"name": "Raeanne Marks", | |
"email": "raeanne.marks@gmail.com", | |
"username": "rmarks" | |
}, | |
"committer": { | |
"name": "Raeanne Marks", | |
"email": "raeanne.marks@gmail.com", | |
"username": "rmarks" | |
}, | |
"added": [ | |
], | |
"removed": [ | |
], | |
"modified": [ | |
"test/FileGenerator.py" | |
] | |
} | |
], | |
"head_commit": { | |
"id": "19c7b1cfdd021cc20ecd85ef3dd0923c859cac7b", | |
"distinct": true, | |
"message": "added a check to get correct amount of bytes from rand", | |
"timestamp": "2014-09-30T14:00:56-07:00", | |
"url": "https://github.eecs.wsu.edu/2014-fall-421-423-arslanay/Wookie/commit/19c7b1cfdd021cc20ecd85ef3dd0923c859cac7b", | |
"author": { | |
"name": "Raeanne Marks", | |
"email": "raeanne.marks@gmail.com", | |
"username": "rmarks" | |
}, | |
"committer": { | |
"name": "Raeanne Marks", | |
"email": "raeanne.marks@gmail.com", | |
"username": "rmarks" | |
}, | |
"added": [ | |
], | |
"removed": [ | |
], | |
"modified": [ | |
"test/FileGenerator.py" | |
] | |
}, | |
"repository": { | |
"id": 460, | |
"name": "Wookie", | |
"url": "https://github.eecs.wsu.edu/2014-fall-421-423-arslanay/Wookie", | |
"description": "\"Highly Scalable TFTP and SFTP server\", sponsored by Isilon.", | |
"watchers": 2, | |
"stargazers": 2, | |
"forks": 0, | |
"fork": false, | |
"size": 564, | |
"owner": { | |
"name": "2014-fall-421-423-arslanay", | |
"email": null | |
}, | |
"private": true, | |
"open_issues": 5, | |
"has_issues": true, | |
"has_downloads": true, | |
"has_wiki": true, | |
"language": "C", | |
"created_at": 1410521112, | |
"pushed_at": 1412110884, | |
"master_branch": "master", | |
"organization": "2014-fall-421-423-arslanay" | |
}, | |
"pusher": { | |
"name": "none" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment