为API添加获取配置型内容的接口

This commit is contained in:
zhlong 2020-06-24 09:50:35 +08:00
parent f0a538d37d
commit 3d25ede46f
2 changed files with 18 additions and 0 deletions

View File

@ -101,6 +101,13 @@ API_EXPORT void API_CALL mk_env_init1(int thread_num,
*/
API_EXPORT void API_CALL mk_set_option(const char *key, const char *val);
/**
*
* @param key
*/
API_EXPORT const char * API_CALL mk_get_option(const char *key);
/**
* http[s]
* @param port htt监听端口800

View File

@ -119,6 +119,17 @@ API_EXPORT void API_CALL mk_set_option(const char *key, const char *val) {
mINI::Instance()[key] = val;
}
API_EXPORT const char * API_CALL mk_get_option(const char *key)
{
assert(key);
if (mINI::Instance().find(key) == mINI::Instance().end()) {
WarnL << "key:" << key << " not existed!";
return nullptr;
}
return mINI::Instance()[key].data();
}
API_EXPORT uint16_t API_CALL mk_http_server_start(uint16_t port, int ssl) {
ssl = MAX(0,MIN(ssl,1));
try {