├── .gitignore ├── CMakeLists.txt ├── LICENSE ├── README.md ├── cmake_install.cmake ├── da4qi4.astylerc ├── include └── daqi │ ├── application.hpp │ ├── client │ └── connection_client.hpp │ ├── connection.hpp │ ├── context.hpp │ ├── cookie.hpp │ ├── da4qi4.hpp │ ├── def │ ├── asio_def.hpp │ ├── boost_def.hpp │ ├── debug_def.hpp │ ├── def.hpp │ ├── inja_def.hpp │ ├── json_def.hpp │ ├── log_def.hpp │ └── redis_def.hpp │ ├── handler.hpp │ ├── intercepter.hpp │ ├── intercepters │ ├── session_redis.hpp │ └── static_file.hpp │ ├── net-detail │ ├── net_detail_client.hpp │ └── net_detail_server.hpp │ ├── redis-client │ ├── redis_buffer.hpp │ ├── redis_client.hpp │ ├── redis_command.hpp │ ├── redis_parser.hpp │ └── redis_value.hpp │ ├── rediscli_pool.hpp │ ├── request.hpp │ ├── response.hpp │ ├── router.hpp │ ├── server.hpp │ ├── server_engine.hpp │ ├── session.hpp │ ├── templates.hpp │ ├── url.hpp │ ├── utilities │ ├── asio_utilities.hpp │ ├── base64_utilities.hpp │ ├── container_utilities.hpp │ ├── des3_utilities.hpp │ ├── encoding_utilities.hpp │ ├── file_utilities.hpp │ ├── hmac_sha1_utilities.hpp │ ├── html_utilities.hpp │ ├── http_utilities.hpp │ ├── md5_utilities.hpp │ └── string_utilities.hpp │ └── websocket │ ├── connection_websocket.hpp │ ├── context_websocket.hpp │ ├── frame_websocket.hpp │ ├── handler_websocket.hpp │ └── websocket.hpp ├── inja ├── bytecode.hpp ├── config.hpp ├── environment.hpp ├── function_storage.hpp ├── inja.hpp ├── lexer.hpp ├── parser.hpp ├── polyfill.hpp ├── renderer.hpp ├── string_view.hpp ├── template.hpp ├── token.hpp └── utils.hpp ├── llhttp ├── CMakeLists.txt ├── LICENSE-MIT ├── README.md ├── api.c ├── helper │ ├── http_status_def.h │ ├── http_url_def.c │ └── http_url_def.h ├── http.c ├── llhttp.c └── llhttp.h ├── multipart-parser ├── .gitignore ├── CMakeLists.txt ├── README.md ├── multipart_parser.c └── multipart_parser.h ├── nlohmann_json ├── .github │ ├── CONTRIBUTING.md │ ├── ISSUE_TEMPLATE │ │ ├── Bug_report.md │ │ └── Feature_request.md │ ├── PULL_REQUEST_TEMPLATE.md │ ├── config.yml │ └── stale.yml ├── .travis.yml ├── CMakeLists.txt ├── CODE_OF_CONDUCT.md ├── ChangeLog.md ├── LICENSE.MIT ├── Makefile ├── README.md ├── appveyor.yml ├── cmake │ └── config.cmake.in ├── include │ └── nlohmann │ │ ├── adl_serializer.hpp │ │ ├── detail │ │ ├── conversions │ │ │ ├── from_json.hpp │ │ │ ├── to_chars.hpp │ │ │ └── to_json.hpp │ │ ├── exceptions.hpp │ │ ├── input │ │ │ ├── binary_reader.hpp │ │ │ ├── input_adapters.hpp │ │ │ ├── json_sax.hpp │ │ │ ├── lexer.hpp │ │ │ ├── parser.hpp │ │ │ └── position_t.hpp │ │ ├── iterators │ │ │ ├── internal_iterator.hpp │ │ │ ├── iter_impl.hpp │ │ │ ├── iteration_proxy.hpp │ │ │ ├── iterator_traits.hpp │ │ │ ├── json_reverse_iterator.hpp │ │ │ └── primitive_iterator.hpp │ │ ├── json_pointer.hpp │ │ ├── json_ref.hpp │ │ ├── macro_scope.hpp │ │ ├── macro_unscope.hpp │ │ ├── meta │ │ │ ├── cpp_future.hpp │ │ │ ├── detected.hpp │ │ │ ├── is_sax.hpp │ │ │ ├── type_traits.hpp │ │ │ └── void_t.hpp │ │ ├── output │ │ │ ├── binary_writer.hpp │ │ │ ├── output_adapters.hpp │ │ │ └── serializer.hpp │ │ └── value_t.hpp │ │ ├── json.hpp │ │ └── json_fwd.hpp ├── meson.build ├── nlohmann_json.natvis └── single_include │ └── nlohmann │ └── json.hpp ├── spdlog ├── async_logger.h ├── common.h ├── contrib │ ├── README.md │ └── sinks │ │ ├── .gitignore │ │ └── step_file_sink.h ├── details │ ├── async_log_helper.h │ ├── async_logger_impl.h │ ├── file_helper.h │ ├── log_msg.h │ ├── logger_impl.h │ ├── mpmc_blocking_q.h │ ├── null_mutex.h │ ├── os.h │ ├── pattern_formatter_impl.h │ ├── registry.h │ └── spdlog_impl.h ├── fmt │ ├── bundled │ │ ├── LICENSE.rst │ │ ├── format.cc │ │ ├── format.h │ │ ├── ostream.cc │ │ ├── ostream.h │ │ ├── posix.cc │ │ ├── posix.h │ │ ├── printf.cc │ │ ├── printf.h │ │ └── time.h │ ├── fmt.h │ └── ostr.h ├── formatter.h ├── logger.h ├── sinks │ ├── android_sink.h │ ├── ansicolor_sink.h │ ├── base_sink.h │ ├── dist_sink.h │ ├── file_sinks.h │ ├── msvc_sink.h │ ├── null_sink.h │ ├── ostream_sink.h │ ├── sink.h │ ├── stdout_sinks.h │ ├── syslog_sink.h │ ├── wincolor_sink.h │ └── windebug_sink.h ├── spdlog.h └── tweakme.h └── src ├── application.cpp ├── client └── connection_client.cpp ├── connection.cpp ├── context.cpp ├── cookie.cpp ├── def ├── boost_def.cpp ├── def.cpp ├── json_def.cpp ├── log_def.cpp └── redis_def.cpp ├── handler.cpp ├── intercepter.cpp ├── intercepters ├── session_redis.cpp └── static_file.cpp ├── main_demo.cpp ├── net-detail ├── net_detail_client.cpp └── net_detail_server.cpp ├── redis-client ├── redis_buffer.cpp ├── redis_client.cpp ├── redis_command.cpp ├── redis_parser.cpp └── redis_value.cpp ├── rediscli_pool.cpp ├── request.cpp ├── response.cpp ├── router.cpp ├── server.cpp ├── server_engine.cpp ├── session.cpp ├── templates.cpp ├── url.cpp ├── utilities ├── asio_utilities.cpp ├── base64_utilities.cpp ├── des3_utilities.cpp ├── encoding_utilities.cpp ├── file_utilities.cpp ├── hmac_sha1_utilities.cpp ├── html_utilities.cpp ├── http_utilities.cpp ├── md5_utilities.cpp └── string_utilities.cpp └── websocket ├── connection_websocket.cpp ├── context_websocket.cpp ├── frame_websocket.cpp └── handler_websocket.cpp /.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | 4 | # Compiled Object files 5 | *.slo 6 | *.lo 7 | *.o 8 | *.obj 9 | 10 | # Precompiled Headers 11 | *.gch 12 | *.pch 13 | 14 | # Compiled Dynamic libraries 15 | *.so 16 | *.dylib 17 | *.dll 18 | 19 | # Fortran module files 20 | *.mod 21 | *.smod 22 | 23 | # Compiled Static libraries 24 | *.lai 25 | *.la 26 | *.a 27 | *.lib 28 | 29 | # Executables 30 | *.exe 31 | *.out 32 | *.app 33 | 34 | # CMakeUserfile 35 | *.user 36 | *.user.* 37 | 38 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.9) 2 | 3 | project(da4qi4) 4 | 5 | #set(_DAQI_TARGET_TYPE_ "DEMO_SERVER") 6 | #set(_DAQI_TARGET_TYPE_ "STATIC_LIB") 7 | #set(_DAQI_TARGET_TYPE_ "SHARED_LIB") 8 | 9 | include_directories(.) 10 | include_directories(include/) 11 | include_directories(nlohmann_json/include/) 12 | 13 | set(USE_LOCAL_BOOST_VERSION OFF) 14 | 15 | if (USE_LOCAL_BOOST_VERSION) 16 | SET(BOOST_INCLUDEDIR /usr/local/include) 17 | SET(BOOST_LIBRARYDIR /usr/local/lib) 18 | find_package(Boost 1.67.0 REQUIRED COMPONENTS filesystem system) 19 | else() 20 | SET(BOOST_INCLUDEDIR /usr/include) 21 | SET(BOOST_LIBRARYDIR /usr/lib) 22 | find_package(Boost 1.65.0 REQUIRED COMPONENTS filesystem system) 23 | endif() 24 | 25 | if (Boost_FOUND) 26 | message(STATUS ${Boost_VERSION}) 27 | message(STATUS ${Boost_INCLUDE_DIRS}) 28 | message(STATUS ${Boost_LIBRARY_DIRS}) 29 | 30 | if ((Boost_VERSION EQUAL 106600) OR (Boost_VERSION GREATER 106600)) 31 | add_definitions(-D_USE_BOOST_VERSION_GE_1_66_=1) 32 | endif() 33 | 34 | add_definitions(-D_USE_BOOST_VERSION_=${Boost_VERSION}) 35 | include_directories(${Boost_INCLUDE_DIRS}) 36 | endif() 37 | 38 | find_library(LIBICONV iconv /usr/local/lib) 39 | 40 | link_libraries(${LIBICONV} pthread) 41 | 42 | set(JSON_MultipleHeaders ON CACHE INTERNAL "") 43 | set(JSON_BuildTests OFF CACHE INTERNAL "") 44 | add_subdirectory(nlohmann_json) 45 | 46 | add_subdirectory(llhttp) 47 | add_subdirectory(multipart-parser) 48 | 49 | aux_source_directory(./src/redis-client DAQI_SRC_FILES) 50 | aux_source_directory(./src/utilities DAQI_SRC_FILES) 51 | aux_source_directory(./src/def DAQI_SRC_FILES) 52 | aux_source_directory(./src/intercepters DAQI_SRC_FILES) 53 | aux_source_directory(./src/client DAQI_SRC_FILES) 54 | aux_source_directory(./src/net-detail DAQI_SRC_FILES) 55 | aux_source_directory(./src/websocket DAQI_SRC_FILES) 56 | aux_source_directory(./src DAQI_SRC_FILES) 57 | 58 | aux_source_directory(./ DAQI_SRC_FILES) 59 | 60 | set(CMAKE_CXX_STANDARD 17) 61 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -Wall") 62 | 63 | link_libraries(multipart_parser) 64 | link_libraries(llhttp) 65 | link_libraries(nlohmann_json) 66 | 67 | if(_DAQI_TARGET_TYPE_ STREQUAL "DEMO_SERVER") 68 | message(STATUS "~BUILD DAQI AS DEMO SERVER~") 69 | link_libraries(ssl) 70 | link_libraries(crypto) 71 | add_definitions(-D_BUILD_DAQI_DEMO_SERVER_=1) 72 | add_executable(${PROJECT_NAME} ${DAQI_SRC_FILES}) 73 | target_link_libraries (${PROJECT_NAME} ${Boost_LIBRARIES}) 74 | elseif(_DAQI_TARGET_TYPE_ STREQUAL "STATIC_LIB") 75 | message(STATUS "~BUILD DAQI AS STATIC LIB~") 76 | add_library(${PROJECT_NAME} STATIC ${DAQI_SRC_FILES}) 77 | set_target_properties (${PROJECT_NAME} PROPERTIES DEBUG_POSTFIX _d) 78 | target_link_libraries (${PROJECT_NAME} ${Boost_LIBRARIES}) 79 | elseif(_DAQI_TARGET_TYPE_ STREQUAL "SHARED_LIB") 80 | message(STATUS "~BUILD DAQI AS SHARED LIB~") 81 | add_library(${PROJECT_NAME} SHARED ${DAQI_SRC_FILES}) 82 | set_target_properties (${PROJECT_NAME} PROPERTIES DEBUG_POSTFIX _d) 83 | endif() 84 | 85 | function(echo_all_cmake_variable_values) 86 | get_cmake_property(vs VARIABLES) 87 | foreach(v ${vs}) 88 | message(STATUS “${v}=’${${v}}'”) 89 | endforeach(v) 90 | message(STATUS “”) 91 | endfunction() 92 | 93 | #echo_all_cmake_variable_values() 94 | -------------------------------------------------------------------------------- /cmake_install.cmake: -------------------------------------------------------------------------------- 1 | # Install script for directory: /home/zhuangyan/Projects/CPP/da4qi4 2 | 3 | # Set the install prefix 4 | if(NOT DEFINED CMAKE_INSTALL_PREFIX) 5 | set(CMAKE_INSTALL_PREFIX "/usr/local") 6 | endif() 7 | string(REGEX REPLACE "/$" "" CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}") 8 | 9 | # Set the install configuration name. 10 | if(NOT DEFINED CMAKE_INSTALL_CONFIG_NAME) 11 | if(BUILD_TYPE) 12 | string(REGEX REPLACE "^[^A-Za-z0-9_]+" "" 13 | CMAKE_INSTALL_CONFIG_NAME "${BUILD_TYPE}") 14 | else() 15 | set(CMAKE_INSTALL_CONFIG_NAME "") 16 | endif() 17 | message(STATUS "Install configuration: \"${CMAKE_INSTALL_CONFIG_NAME}\"") 18 | endif() 19 | 20 | # Set the component getting installed. 21 | if(NOT CMAKE_INSTALL_COMPONENT) 22 | if(COMPONENT) 23 | message(STATUS "Install component: \"${COMPONENT}\"") 24 | set(CMAKE_INSTALL_COMPONENT "${COMPONENT}") 25 | else() 26 | set(CMAKE_INSTALL_COMPONENT) 27 | endif() 28 | endif() 29 | 30 | # Install shared libraries without execute permission? 31 | if(NOT DEFINED CMAKE_INSTALL_SO_NO_EXE) 32 | set(CMAKE_INSTALL_SO_NO_EXE "1") 33 | endif() 34 | 35 | # Is this installation the result of a crosscompile? 36 | if(NOT DEFINED CMAKE_CROSSCOMPILING) 37 | set(CMAKE_CROSSCOMPILING "FALSE") 38 | endif() 39 | 40 | if(NOT CMAKE_INSTALL_LOCAL_ONLY) 41 | # Include the install script for each subdirectory. 42 | include("/home/zhuangyan/Projects/CPP/da4qi4/nlohmann_json/cmake_install.cmake") 43 | 44 | endif() 45 | 46 | if(CMAKE_INSTALL_COMPONENT) 47 | set(CMAKE_INSTALL_MANIFEST "install_manifest_${CMAKE_INSTALL_COMPONENT}.txt") 48 | else() 49 | set(CMAKE_INSTALL_MANIFEST "install_manifest.txt") 50 | endif() 51 | 52 | string(REPLACE ";" "\n" CMAKE_INSTALL_MANIFEST_CONTENT 53 | "${CMAKE_INSTALL_MANIFEST_FILES}") 54 | file(WRITE "/home/zhuangyan/Projects/CPP/da4qi4/${CMAKE_INSTALL_MANIFEST}" 55 | "${CMAKE_INSTALL_MANIFEST_CONTENT}") 56 | -------------------------------------------------------------------------------- /da4qi4.astylerc: -------------------------------------------------------------------------------- 1 | # Allman Coding Style Options 2 | # Based on an old AStyle release. 3 | 4 | # braces and indent 5 | style=allman 6 | indent=spaces 7 | 8 | # indentation 9 | min-conditional-indent=0 10 | max-continuation-indent=80 11 | indent-switches 12 | indent-continuation=3 13 | indent-preproc-block 14 | indent-preproc-define 15 | indent-col1-comments 16 | 17 | # padding 18 | pad-oper 19 | pad-header 20 | unpad-paren 21 | align-pointer=type 22 | break-blocks 23 | pad-oper 24 | pad-header 25 | align-pointer=type 26 | align-reference=type 27 | 28 | # formatting 29 | break-one-line-headers 30 | break-closing-braces 31 | keep-one-line-statements 32 | convert-tabs 33 | add-braces 34 | close-templates 35 | max-code-length=120 36 | 37 | 38 | -------------------------------------------------------------------------------- /include/daqi/da4qi4.hpp: -------------------------------------------------------------------------------- 1 | #ifndef DAQI_DA4QI4_HPP 2 | #define DAQI_DA4QI4_HPP 3 | 4 | #include "daqi/def/log_def.hpp" 5 | 6 | #include "daqi/server.hpp" 7 | #include "daqi/router.hpp" 8 | #include "daqi/application.hpp" 9 | 10 | #endif // DAQI_DA4QI4_HPP 11 | -------------------------------------------------------------------------------- /include/daqi/def/asio_def.hpp: -------------------------------------------------------------------------------- 1 | #ifndef DAQI_ASIO_DEF_HPP 2 | #define DAQI_ASIO_DEF_HPP 3 | 4 | #include 5 | #include 6 | 7 | namespace da4qi4 8 | { 9 | 10 | #ifdef _USE_BOOST_VERSION_GE_1_66_ 11 | #define HAS_IO_CONTEXT 12 | #define HAS_RESOLVER_RESULT 13 | #endif 14 | 15 | #ifdef HAS_IO_CONTEXT 16 | using IOC = boost::asio::io_context; 17 | #else 18 | using IOC = boost::asio::io_service; 19 | #endif 20 | 21 | using Tcp = boost::asio::ip::tcp; 22 | 23 | #ifdef HAS_RESOLVER_TYPE_RESULT 24 | typedef Tcp::resolver::results_type ResolverResultT; 25 | #else 26 | typedef Tcp::resolver::iterator ResolverResultT; 27 | #endif 28 | 29 | typedef boost::asio::ssl::context_base SSLContextBase; 30 | 31 | } 32 | 33 | #endif // DAQI_ASIO_DEF_HPP 34 | -------------------------------------------------------------------------------- /include/daqi/def/boost_def.hpp: -------------------------------------------------------------------------------- 1 | #ifndef DAQI_BOOST_DEF_HPP 2 | #define DAQI_BOOST_DEF_HPP 3 | 4 | #include 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | namespace da4qi4 13 | { 14 | 15 | extern boost::none_t NoneObject; 16 | using errorcode = boost::system::error_code; 17 | namespace fs = boost::filesystem; 18 | 19 | using OptionalString = boost::optional; 20 | using OptionalStringRef = boost::optional; 21 | using OptionalStringRefConst = boost::optional; 22 | 23 | namespace asio_placeholders = boost::asio::placeholders; 24 | 25 | } //namesapce da4qi4 26 | 27 | #endif // DAQI_BOOST_DEF_HPP 28 | -------------------------------------------------------------------------------- /include/daqi/def/debug_def.hpp: -------------------------------------------------------------------------------- 1 | #ifndef DAQI_DEBUG_DEF_HPP 2 | #define DAQI_DEBUG_DEF_HPP 3 | 4 | #include 5 | 6 | #endif // DAQI_DEBUG_DEF_HPP 7 | -------------------------------------------------------------------------------- /include/daqi/def/def.hpp: -------------------------------------------------------------------------------- 1 | #ifndef DAQI_DEF_HPP 2 | #define DAQI_DEF_HPP 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | #include "daqi/utilities/string_utilities.hpp" 13 | 14 | namespace da4qi4 15 | { 16 | 17 | extern char const* const the_daqi_name; 18 | extern char const* const the_daqi_version; 19 | 20 | enum class CacheControl {Public, Private}; 21 | enum PathResolve {is_relative, is_absolute}; //for url and dist-directory 22 | 23 | using Headers = std::map; 24 | using ICHeaders = std::map; 25 | using ICCookies = ICHeaders; 26 | using UrlParameters = std::map; 27 | 28 | } //namespace da4qi4 29 | 30 | #endif // DAQI_DEF_HPP 31 | -------------------------------------------------------------------------------- /include/daqi/def/inja_def.hpp: -------------------------------------------------------------------------------- 1 | #ifndef DAQI_INJA_DEF_HPP 2 | #define DAQI_INJA_DEF_HPP 3 | 4 | #include 5 | 6 | #include "inja/inja.hpp" 7 | 8 | namespace da4qi4 9 | { 10 | 11 | using Template = inja::Template; 12 | using TemplatePtr = std::shared_ptr