install workflow by source build
# bash
git clone https://github.com/sogou/workflow
cd workflow
cmake -B b
cd b
make -j4
sudo make install
use simple tutorial
// filename: tw.cpp
#include <iostream>
#include <workflow/WFHttpServer.h>
int main()
{
// server
WFHttpServer server([](WFHttpTask *task)
{
task->get_resp()->append_output_body("<h1> hello world</h1>");
});
if (server.start(8888) == 0) {
getchar();
server.stop();
}
}
build by cmake 3.20+
# filename:CMakeLists.txt
cmake_minimum_required(VERSION 3.20)
find_library(LIBRT rt)
find_package(OpenSSL REQUIRED)
find_package(workflow REQUIRED CONFIG HINTS ..)
include_directories(${OPENSSL_INCLUDE_DIR} ${WORKFLOW_INCLUDE_DIR})
link_directories(${WORKFLOW_LIB_DIR})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -fPIC -pipe -std=c++11 -fno-exceptions")
set(WORKFLOW_LIB workflow pthread OpenSSL::SSL OpenSSL::Crypto ${LIBRT})
# application here
add_executable(tw tw.cpp)
target_link_libraries(tw ${WORKFLOW_LIB})
run and check server
#bash
curl localhost:8888
or use browser to get url localhost:8888