webhook

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GithubSignatureHeader = "X-Hub-Signature-256"
	GiteaSignatureHeader  = "X-Gitea-Signature"
	GitlabTokenHeader     = "X-Gitlab-Token"
)

Variables

View Source
var (
	ErrInvalidHTTPMethod = errors.New("invalid http method")
	ErrParsingPayload    = errors.New("failed to parse payload")
)
View Source
var (
	ErrHMACVerificationFailed        = errors.New("HMAC verification failed")
	ErrGitlabTokenVerificationFailed = errors.New("gitlab token verification failed")
	ErrMissingSecurityHeader         = errors.New("missing signature or token header")
)

Functions

func GenerateHMAC added in v0.7.1

func GenerateHMAC(payload []byte, secretKey string) string

Types

type GithubPushPayload

type GithubPushPayload struct {
	Ref        string `json:"ref"`
	CommitSHA  string `json:"after"`
	Repository struct {
		Name     string `json:"name"`
		FullName string `json:"full_name"`
		CloneURL string `json:"clone_url"`
		Private  bool   `json:"private"`
	} `json:"repository"`
}

GithubPushPayload is a struct that represents the payload sent by GitHub or Gitea, as they have the same structure

type GitlabPushPayload

type GitlabPushPayload struct {
	Ref        string `json:"ref"`
	CommitSHA  string `json:"after"`
	Repository struct {
		Name              string `json:"name"`
		PathWithNamespace string `json:"path_with_namespace"`
		CloneURL          string `json:"http_url"`
		VisibilityLevel   int64  `json:"visibility_level"`
	} `json:"project"`
}

GitlabPushPayload is a struct that represents the payload sent by GitLab

type ParsedPayload

type ParsedPayload struct {
	Ref       string
	CommitSHA string
	Name      string
	FullName  string
	CloneURL  string
	Private   bool
}

ParsedPayload is a struct that contains the parsed payload data

func Parse

func Parse(r *http.Request, secretKey string) (ParsedPayload, error)

Parse parses the payload and returns the parsed payload data

Jump to

Keyboard shortcuts

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