mirror of
https://github.com/ncarlier/webhookd.git
synced 2025-04-12 05:54:49 +00:00
28 lines
485 B
Go
28 lines
485 B
Go
package hook
|
|
|
|
import (
|
|
"errors"
|
|
"net/http"
|
|
)
|
|
|
|
type Record interface {
|
|
GetURL() string
|
|
GetName() string
|
|
Decode(r *http.Request) error
|
|
}
|
|
|
|
func RecordFactory(hookname string) (Record, error) {
|
|
switch hookname {
|
|
case "bitbucket":
|
|
return new(BitbucketRecord), nil
|
|
case "github":
|
|
return new(GithubRecord), nil
|
|
case "gitlab":
|
|
return new(GitlabRecord), nil
|
|
case "docker":
|
|
return new(DockerRecord), nil
|
|
default:
|
|
return nil, errors.New("Unknown hookname: " + hookname)
|
|
}
|
|
}
|