mirror of
https://github.com/casdoor/casdoor.git
synced 2025-07-03 20:50:19 +08:00
Add headers to webhook.
This commit is contained in:
@ -16,11 +16,11 @@ package object
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/casbin/casdoor/util"
|
||||
"runtime"
|
||||
|
||||
"github.com/astaxie/beego"
|
||||
"github.com/casbin/casdoor/conf"
|
||||
"github.com/casbin/casdoor/util"
|
||||
//_ "github.com/denisenkom/go-mssqldb" // db = mssql
|
||||
_ "github.com/go-sql-driver/mysql" // db = mysql
|
||||
//_ "github.com/lib/pq" // db = postgres
|
||||
@ -185,4 +185,4 @@ func GetSession(owner string, offset, limit int, field, value, sortField, sortOr
|
||||
session = session.Desc(util.SnakeString(sortField))
|
||||
}
|
||||
return session
|
||||
}
|
||||
}
|
||||
|
@ -21,17 +21,23 @@ import (
|
||||
"xorm.io/core"
|
||||
)
|
||||
|
||||
type Header struct {
|
||||
Name string `json:"name"`
|
||||
Value string `json:"value"`
|
||||
}
|
||||
|
||||
type Webhook struct {
|
||||
Owner string `xorm:"varchar(100) notnull pk" json:"owner"`
|
||||
Name string `xorm:"varchar(100) notnull pk" json:"name"`
|
||||
CreatedTime string `xorm:"varchar(100)" json:"createdTime"`
|
||||
|
||||
Url string `xorm:"varchar(100)" json:"url"`
|
||||
Method string `xorm:"varchar(100)" json:"method"`
|
||||
ContentType string `xorm:"varchar(100)" json:"contentType"`
|
||||
Events []string `xorm:"varchar(100)" json:"events"`
|
||||
|
||||
Organization string `xorm:"varchar(100) index" json:"organization"`
|
||||
|
||||
Url string `xorm:"varchar(100)" json:"url"`
|
||||
Method string `xorm:"varchar(100)" json:"method"`
|
||||
ContentType string `xorm:"varchar(100)" json:"contentType"`
|
||||
Headers []*Header `xorm:"mediumtext" json:"headers"`
|
||||
Events []string `xorm:"varchar(100)" json:"events"`
|
||||
}
|
||||
|
||||
func GetWebhookCount(owner, field, value string) int {
|
||||
|
@ -33,6 +33,10 @@ func sendWebhook(webhook *Webhook, record *Record) error {
|
||||
|
||||
req.Header.Set("Content-Type", webhook.ContentType)
|
||||
|
||||
for _, header := range webhook.Headers {
|
||||
req.Header.Set(header.Name, header.Value)
|
||||
}
|
||||
|
||||
_, err = client.Do(req)
|
||||
return err
|
||||
}
|
||||
|
Reference in New Issue
Block a user