ZLMediaKit/server/WebHook.h

42 lines
1.1 KiB
C++
Raw Normal View History

2019-08-08 19:01:45 +08:00
/*
2020-04-04 20:30:09 +08:00
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
2019-06-24 14:50:50 +08:00
*
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
2019-06-24 14:50:50 +08:00
*
2020-04-04 20:30:09 +08:00
* Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors
* may be found in the AUTHORS file in the root of the source tree.
2019-06-24 14:50:50 +08:00
*/
#ifndef ZLMEDIAKIT_WEBHOOK_H
#define ZLMEDIAKIT_WEBHOOK_H
#include <string>
2020-12-27 22:14:59 +08:00
#include <functional>
#include "json/json.h"
2020-12-27 22:14:59 +08:00
//支持json或urlencoded方式传输参数
#define JSON_ARGS
#ifdef JSON_ARGS
typedef Json::Value ArgsType;
2020-12-27 22:14:59 +08:00
#else
typedef mediakit::HttpArgs ArgsType;
2020-12-27 22:14:59 +08:00
#endif
2019-06-24 14:50:50 +08:00
namespace Hook {
2020-12-27 22:14:59 +08:00
//web hook回复最大超时时间
extern const std::string kTimeoutSec;
2019-06-24 14:50:50 +08:00
}//namespace Hook
2019-06-24 14:58:56 +08:00
void installWebHook();
void unInstallWebHook();
2020-12-27 22:14:59 +08:00
/**
* http hook请求
* @param url
* @param body body
* @param func
*/
void do_http_hook(const std::string &url, const ArgsType &body, const std::function<void(const Json::Value &, const std::string &)> &func = nullptr);
2019-06-24 14:50:50 +08:00
#endif //ZLMEDIAKIT_WEBHOOK_H