ZLMediaKit/server/WebHook.h

52 lines
1.4 KiB
C++
Raw Permalink Normal View History

2019-08-08 19:01:45 +08:00
/*
2023-12-09 16:23:51 +08:00
* Copyright (c) 2016-present The ZLMediaKit project authors. All Rights Reserved.
2019-06-24 14:50:50 +08:00
*
2023-12-09 16:23:51 +08:00
* This file is part of ZLMediaKit(https://github.com/ZLMediaKit/ZLMediaKit).
2019-06-24 14:50:50 +08:00
*
2023-12-09 16:23:51 +08:00
* Use of this source code is governed by MIT-like license that can be found in the
2020-04-04 20:30:09 +08:00
* 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方式传输参数 [AUTO-TRANSLATED:0e14d484]
// // Support json or urlencoded way to transmit parameters
2020-12-27 22:14:59 +08:00
#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 {
// web hook回复最大超时时间 [AUTO-TRANSLATED:9a059363]
// Maximum timeout for web hook reply
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();
void onProcessExited();
2020-12-27 22:14:59 +08:00
/**
* http hook请求
* @param url
* @param body body
* @param func
* Trigger http hook request
* @param url Request address
* @param body Request body
* @param func Callback
* [AUTO-TRANSLATED:8ffdd09b]
2020-12-27 22:14:59 +08:00
*/
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