Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
Z
ZLMediaKit
概览
Overview
Details
Activity
Cycle Analytics
版本库
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
问题
0
Issues
0
列表
Board
标记
里程碑
合并请求
0
Merge Requests
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
Snippets
成员
Collapse sidebar
Close sidebar
活动
图像
聊天
创建新问题
作业
提交
Issue Boards
Open sidebar
张翔宇
ZLMediaKit
Commits
b7e6bfb5
Commit
b7e6bfb5
authored
3 years ago
by
xiongziliang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
hook接口在http头中附带vhost:#872
parent
7641db42
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
20 行增加
和
5 行删除
+20
-5
server/WebApi.cpp
+1
-1
server/WebHook.cpp
+19
-4
没有找到文件。
server/WebApi.cpp
查看文件 @
b7e6bfb5
...
...
@@ -250,7 +250,7 @@ static inline string getProxyKey(const string &vhost,const string &app,const str
Value
makeMediaSourceJson
(
MediaSource
&
media
){
Value
item
;
item
[
"schema"
]
=
media
.
getSchema
();
item
[
"vhost"
]
=
media
.
getVhost
();
item
[
VHOST_KEY
]
=
media
.
getVhost
();
item
[
"app"
]
=
media
.
getApp
();
item
[
"stream"
]
=
media
.
getId
();
item
[
"createStamp"
]
=
(
Json
::
UInt64
)
media
.
getCreateStamp
();
...
...
This diff is collapsed.
Click to expand it.
server/WebHook.cpp
查看文件 @
b7e6bfb5
...
...
@@ -113,6 +113,17 @@ const char *getContentType(const HttpArgs &value){
return
"application/x-www-form-urlencoded"
;
}
string
getVhost
(
const
Value
&
value
)
{
const
char
*
key
=
VHOST_KEY
;
auto
val
=
value
.
find
(
key
,
key
+
sizeof
(
VHOST_KEY
)
-
1
);
return
val
?
val
->
asString
()
:
""
;
}
string
getVhost
(
const
HttpArgs
&
value
)
{
auto
val
=
value
.
find
(
VHOST_KEY
);
return
val
!=
value
.
end
()
?
val
->
second
:
""
;
}
void
do_http_hook
(
const
string
&
url
,
const
ArgsType
&
body
,
const
function
<
void
(
const
Value
&
,
const
string
&
)
>
&
func
){
GET_CONFIG
(
string
,
mediaServerId
,
General
::
kMediaServerId
);
GET_CONFIG
(
float
,
hook_timeoutSec
,
Hook
::
kTimeoutSec
);
...
...
@@ -123,6 +134,10 @@ void do_http_hook(const string &url,const ArgsType &body,const function<void(con
auto
bodyStr
=
to_string
(
body
);
requester
->
setBody
(
bodyStr
);
requester
->
addHeader
(
"Content-Type"
,
getContentType
(
body
));
auto
vhost
=
getVhost
(
body
);
if
(
!
vhost
.
empty
())
{
requester
->
addHeader
(
"X-VHOST"
,
vhost
);
}
std
::
shared_ptr
<
Ticker
>
pTicker
(
new
Ticker
);
requester
->
startRequester
(
url
,
[
url
,
func
,
bodyStr
,
requester
,
pTicker
](
const
SockException
&
ex
,
const
string
&
status
,
...
...
@@ -147,7 +162,7 @@ void do_http_hook(const string &url,const ArgsType &body,const function<void(con
static
ArgsType
make_json
(
const
MediaInfo
&
args
){
ArgsType
body
;
body
[
"schema"
]
=
args
.
_schema
;
body
[
"vhost"
]
=
args
.
_vhost
;
body
[
VHOST_KEY
]
=
args
.
_vhost
;
body
[
"app"
]
=
args
.
_app
;
body
[
"stream"
]
=
args
.
_streamid
;
body
[
"params"
]
=
args
.
_param_strs
;
...
...
@@ -306,7 +321,7 @@ void installWebHook(){
body
[
"regist"
]
=
bRegist
;
}
else
{
body
[
"schema"
]
=
sender
.
getSchema
();
body
[
"vhost"
]
=
sender
.
getVhost
();
body
[
VHOST_KEY
]
=
sender
.
getVhost
();
body
[
"app"
]
=
sender
.
getApp
();
body
[
"stream"
]
=
sender
.
getId
();
body
[
"regist"
]
=
bRegist
;
...
...
@@ -342,7 +357,7 @@ void installWebHook(){
body
[
"url"
]
=
info
.
url
;
body
[
"app"
]
=
info
.
app
;
body
[
"stream"
]
=
info
.
stream
;
body
[
"vhost"
]
=
info
.
vhost
;
body
[
VHOST_KEY
]
=
info
.
vhost
;
return
body
;
};
...
...
@@ -394,7 +409,7 @@ void installWebHook(){
ArgsType
body
;
body
[
"schema"
]
=
sender
.
getSchema
();
body
[
"vhost"
]
=
sender
.
getVhost
();
body
[
VHOST_KEY
]
=
sender
.
getVhost
();
body
[
"app"
]
=
sender
.
getApp
();
body
[
"stream"
]
=
sender
.
getId
();
weak_ptr
<
MediaSource
>
weakSrc
=
sender
.
shared_from_this
();
...
...
This diff is collapsed.
Click to expand it.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论