ghwebhook

package module
v0.0.0-...-7416295 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 26, 2017 License: MIT Imports: 11 Imported by: 1

README

ghwebhook

USAGE

package main

import (
	"log"
	"net/http"

	"github.com/google/go-github/github"
	"github.com/shogo82148/ghwebhook"
)

func main() {
	h := &ghwebhook.Webhook{
		// recommend to set secret
		Secret:       "very-secret-string",

		// Restrict IP address
		RestrictAddr: true,
		TrustAddrs:   []string{"::1/128", "127.0.0.0/8"},

		Ping: func(e *github.PingEvent) {
			log.Printf("%#v", e)
		},
	}
	http.ListenAndServe(":8080", h)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Webhook

type Webhook struct {
	// Secret is Secret in Github Settings/Webhooks/Manage webhook
	Secret string

	// RestrictAddr enables restrict Service Hook IP Addresses
	// https://help.github.com/articles/github-s-ip-addresses/
	RestrictAddr bool

	// TrustAddrs is the list of trusted IP address (e.g. reverse proxies)
	TrustAddrs []string

	CommitComment            func(e *github.CommitCommentEvent)
	Create                   func(e *github.CreateEvent)
	Delete                   func(e *github.DeleteEvent)
	Deployment               func(e *github.DeploymentEvent)
	DeploymentStatus         func(e *github.DeploymentStatusEvent)
	Fork                     func(e *github.ForkEvent)
	Gollum                   func(e *github.GollumEvent)
	Installation             func(e *github.InstallationEvent)
	InstallationRepositories func(e *github.InstallationRepositoriesEvent)
	IssueComment             func(e *github.IssueCommentEvent)
	Issues                   func(e *github.IssuesEvent)
	Label                    func(e *github.LabelEvent)
	Member                   func(e *github.MemberEvent)
	Membership               func(e *github.MembershipEvent)
	Milestone                func(e *github.MilestoneEvent)
	Organization             func(e *github.OrganizationEvent)
	OrgBlock                 func(e *github.OrgBlockEvent)
	PageBuild                func(e *github.PageBuildEvent)
	Ping                     func(e *github.PingEvent)
	Project                  func(e *github.ProjectEvent)
	ProjectCard              func(e *github.ProjectCardEvent)
	ProjectColumn            func(e *github.ProjectColumnEvent)
	Public                   func(e *github.PublicEvent)
	PullRequestReview        func(e *github.PullRequestReviewEvent)
	PullRequestReviewComment func(e *github.PullRequestReviewCommentEvent)
	PullRequest              func(e *github.PullRequestEvent)
	Push                     func(e *github.PushEvent)
	Repository               func(e *github.RepositoryEvent)
	Release                  func(e *github.ReleaseEvent)
	Status                   func(e *github.StatusEvent)
	Team                     func(e *github.TeamEvent)
	TeamAdd                  func(e *github.TeamAddEvent)
	Watch                    func(e *github.WatchEvent)
	// contains filtered or unexported fields
}

Webhook is a receiver for github webhook.

func (*Webhook) ServeHTTP

func (h *Webhook) ServeHTTP(w http.ResponseWriter, r *http.Request)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL