mirror of
https://github.com/casdoor/casdoor.git
synced 2025-07-03 12:30:19 +08:00
Add method to webhook.
This commit is contained in:
@ -27,6 +27,7 @@ type Webhook struct {
|
||||
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"`
|
||||
|
||||
|
@ -26,7 +26,7 @@ func sendWebhook(webhook *Webhook, record *Record) error {
|
||||
|
||||
body := strings.NewReader(util.StructToJson(record))
|
||||
|
||||
req, err := http.NewRequest("POST", webhook.Url, body)
|
||||
req, err := http.NewRequest(webhook.Method, webhook.Url, body)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -114,6 +114,23 @@ class WebhookEditPage extends React.Component {
|
||||
}} />
|
||||
</Col>
|
||||
</Row>
|
||||
<Row style={{marginTop: '20px'}} >
|
||||
<Col style={{marginTop: '5px'}} span={(Setting.isMobile()) ? 22 : 2}>
|
||||
{Setting.getLabel(i18next.t("webhook:Method"), i18next.t("webhook:Method - Tooltip"))} :
|
||||
</Col>
|
||||
<Col span={22} >
|
||||
<Select virtual={false} style={{width: '100%'}} value={this.state.webhook.method} onChange={(value => {this.updateWebhookField('method', value);})}>
|
||||
{
|
||||
[
|
||||
{id: 'POST', name: 'POST'},
|
||||
{id: 'GET', name: 'GET'},
|
||||
{id: 'PUT', name: 'PUT'},
|
||||
{id: 'DELETE', name: 'DELETE'},
|
||||
].map((method, index) => <Option key={index} value={method.id}>{method.name}</Option>)
|
||||
}
|
||||
</Select>
|
||||
</Col>
|
||||
</Row>
|
||||
<Row style={{marginTop: '20px'}} >
|
||||
<Col style={{marginTop: '5px'}} span={(Setting.isMobile()) ? 22 : 2}>
|
||||
{Setting.getLabel(i18next.t("webhook:Content type"), i18next.t("webhook:Content type - Tooltip"))} :
|
||||
|
@ -20,10 +20,8 @@ import * as Setting from "./Setting";
|
||||
import * as WebhookBackend from "./backend/WebhookBackend";
|
||||
import i18next from "i18next";
|
||||
import BaseListPage from "./BaseListPage";
|
||||
import * as ProviderBackend from "./backend/ProviderBackend";
|
||||
|
||||
class WebhookListPage extends BaseListPage {
|
||||
|
||||
newWebhook() {
|
||||
const randomName = Setting.getRandomName();
|
||||
return {
|
||||
@ -31,6 +29,7 @@ class WebhookListPage extends BaseListPage {
|
||||
name: `webhook_${randomName}`,
|
||||
createdTime: moment().format(),
|
||||
url: "https://example.com/callback",
|
||||
method: "POST",
|
||||
contentType: "application/json",
|
||||
events: ["signup", "login", "logout", "update-user"],
|
||||
organization: "built-in",
|
||||
@ -125,11 +124,19 @@ class WebhookListPage extends BaseListPage {
|
||||
)
|
||||
}
|
||||
},
|
||||
{
|
||||
title: i18next.t("webhook:Method"),
|
||||
dataIndex: 'method',
|
||||
key: 'method',
|
||||
width: '120px',
|
||||
sorter: true,
|
||||
...this.getColumnSearchProps('method'),
|
||||
},
|
||||
{
|
||||
title: i18next.t("webhook:Content type"),
|
||||
dataIndex: 'contentType',
|
||||
key: 'contentType',
|
||||
width: '150px',
|
||||
width: '200px',
|
||||
sorter: true,
|
||||
filterMultiple: false,
|
||||
filters: [
|
||||
|
Reference in New Issue
Block a user