1 Star 1 Fork 0

zdzhaoyong / svar_http

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
README.md 1.12 KB
一键复制 编辑 原始数据 按行查看 历史
zdzhaoyong 提交于 2020-04-16 15:16 . add README.md

Svar HTTP : Call Svar Module Through Internet

Install

Install PICMake first: https://github.com/zdzhaoyong/PICMake Install Svar : https://github.com/zdzhaoyong/Svar

Clone code and Install with cmake:

git clone https://github.com/zdzhaoyong/svar_http

mkdir svar_http/build
cd svar_http/build
cmake .. -DCMAKE_BUILD_TYPE=Release
make
sudo make install

Use

Put all APIs in a Svar object and serve it with one line!

This is very small demo:

#include <Svar/Registry.h>

using namespace sv;

auto http=Registry::load("svar_http");

std::string md5(Svar paras){
    std::string str=paras["str"].castAs<std::string>();
    std::cerr<<paras<<std::endl<<str<<std::endl;
    std::string ret=SvarBuffer(str.data(),str.size()).clone().md5();
    return ret;
}

double sum(Svar paras){
    double x=std::stod(paras["x"].as<std::string>());
    double y=std::stod(paras["y"].as<std::string>());

    return x+y;
}

int main(int argc,char** argv){
    svar["md5"]=md5;
    svar["sum"]=sum;

    auto Server=http["Server"]("0.0.0.0",1234,svar);

    sleep(1000);
    return 0;
}

Run this demo with "./http_demo".

1
https://gitee.com/zdzhaoyong/svar_http.git
git@gitee.com:zdzhaoyong/svar_http.git
zdzhaoyong
svar_http
svar_http
master

搜索帮助