Skip to content

Commit

Permalink
add support for swagger
Browse files Browse the repository at this point in the history
  • Loading branch information
an-tao committed Jul 24, 2021
1 parent 1c04b1a commit a2e1190
Show file tree
Hide file tree
Showing 18 changed files with 415 additions and 294 deletions.
232 changes: 49 additions & 183 deletions CMakeLists.txt
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ option(BUILD_EXAMPLES "Build examples" ${BUILD_PROGRAMS})
option(BUILD_ORM "Build orm" ON)
option(COZ_PROFILING "Use coz for profiling" OFF)
option(BUILD_DROGON_SHARED "Build drogon as a shared lib" OFF)
option(BUILD_DOC "Build Doxygen documentation" OFF)

include(CMakeDependentOption)
CMAKE_DEPENDENT_OPTION(BUILD_POSTGRESQL "Build with postgresql support" ON "BUILD_ORM" OFF)
Expand Down Expand Up @@ -240,50 +239,11 @@ set(DROGON_SOURCES
lib/src/WebSocketClientImpl.cc
lib/src/WebSocketConnectionImpl.cc
lib/src/WebsocketControllersRouter.cc)
set(private_headers
lib/src/AOPAdvice.h
lib/src/CacheFile.h
lib/src/ConfigLoader.h
lib/src/filesystem.h
lib/src/FiltersFunction.h
lib/src/HttpAppFrameworkImpl.h
lib/src/HttpClientImpl.h
lib/src/HttpControllersRouter.h
lib/src/HttpFileImpl.h
lib/src/HttpFileUploadRequest.h
lib/src/HttpMessageBody.h
lib/src/HttpRequestImpl.h
lib/src/HttpRequestParser.h
lib/src/HttpResponseImpl.h
lib/src/HttpResponseParser.h
lib/src/HttpServer.h
lib/src/HttpSimpleControllersRouter.h
lib/src/HttpUtils.h
lib/src/impl_forwards.h
lib/src/ListenerManager.h
lib/src/PluginsManager.h
lib/src/SessionManager.h
lib/src/SpinLock.h
lib/src/StaticFileRouter.h
lib/src/TaskTimeoutFlag.h
lib/src/WebSocketClientImpl.h
lib/src/WebSocketConnectionImpl.h
lib/src/WebsocketControllersRouter.h)

if (NOT WIN32)
set(DROGON_SOURCES
${DROGON_SOURCES}
lib/src/SharedLibManager.cc)
set(private_headers
${private_headers}
lib/src/SharedLibManager.h)
set(DROGON_SOURCES ${DROGON_SOURCES} lib/src/SharedLibManager.cc)
else (NOT WIN32)
set(DROGON_SOURCES
${DROGON_SOURCES}
third_party/mman-win32/mman.c)
set(private_headers
${private_headers}
third_party/mman-win32/mman.h)
set(DROGON_SOURCES ${DROGON_SOURCES} third_party/mman-win32/mman.c)
endif (NOT WIN32)

if (BUILD_POSTGRESQL)
Expand All @@ -293,12 +253,8 @@ if (BUILD_POSTGRESQL)
message(STATUS "libpq inc path:" ${PG_INCLUDE_DIRS})
message(STATUS "libpq lib:" ${PG_LIBRARIES})
target_link_libraries(${PROJECT_NAME} PRIVATE pg_lib)
set(DROGON_SOURCES
${DROGON_SOURCES}
set(DROGON_SOURCES ${DROGON_SOURCES}
orm_lib/src/postgresql_impl/PostgreSQLResultImpl.cc)
set(private_headers
${private_headers}
orm_lib/src/postgresql_impl/PostgreSQLResultImpl.h)
if (LIBPQ_BATCH_MODE)
try_compile(libpq_supports_batch ${CMAKE_BINARY_DIR}/cmaketest
${PROJECT_SOURCE_DIR}/cmake/tests/test_libpq_batch_mode.cc
Expand All @@ -308,17 +264,12 @@ if (BUILD_POSTGRESQL)
if (libpq_supports_batch)
message(STATUS "The libpq supports batch mode")
option(LIBPQ_SUPPORTS_BATCH_MODE "libpq batch mode" ON)
set(DROGON_SOURCES
${DROGON_SOURCES}
set(DROGON_SOURCES ${DROGON_SOURCES}
orm_lib/src/postgresql_impl/PgBatchConnection.cc)
else (libpq_supports_batch)
option(LIBPQ_SUPPORTS_BATCH_MODE "libpq batch mode" OFF)
set(DROGON_SOURCES
${DROGON_SOURCES}
set(DROGON_SOURCES ${DROGON_SOURCES}
orm_lib/src/postgresql_impl/PgConnection.cc)
set(private_headers
${private_headers}
orm_lib/src/postgresql_impl/PgConnection.h)
endif (libpq_supports_batch)
endif (pg_FOUND)
endif (BUILD_POSTGRESQL)
Expand All @@ -329,14 +280,9 @@ if (BUILD_MYSQL)
if (MySQL_FOUND)
message(STATUS "Ok! We find the mariadb!")
target_link_libraries(${PROJECT_NAME} PRIVATE MySQL_lib)
set(DROGON_SOURCES
${DROGON_SOURCES}
set(DROGON_SOURCES ${DROGON_SOURCES}
orm_lib/src/mysql_impl/MysqlConnection.cc
orm_lib/src/mysql_impl/MysqlResultImpl.cc)
set(private_headers
${private_headers}
orm_lib/src/mysql_impl/MysqlConnection.h
orm_lib/src/mysql_impl/MysqlResultImpl.h)
endif (MySQL_FOUND)
endif (BUILD_MYSQL)

Expand All @@ -345,14 +291,9 @@ if (BUILD_SQLITE)
find_package(SQLite3)
if (SQLite3_FOUND)
target_link_libraries(${PROJECT_NAME} PRIVATE SQLite3_lib)
set(DROGON_SOURCES
${DROGON_SOURCES}
set(DROGON_SOURCES ${DROGON_SOURCES}
orm_lib/src/sqlite3_impl/Sqlite3Connection.cc
orm_lib/src/sqlite3_impl/Sqlite3ResultImpl.cc)
set(private_headers
${private_headers}
orm_lib/src/sqlite3_impl/Sqlite3Connection.h
orm_lib/src/sqlite3_impl/Sqlite3ResultImpl.h)
endif (SQLite3_FOUND)
endif (BUILD_SQLITE)

Expand All @@ -364,17 +305,11 @@ if (BUILD_REDIS)
set(DROGON_SOURCES
${DROGON_SOURCES}
nosql_lib/redis/src/RedisClientImpl.cc
nosql_lib/redis/src/RedisClientLockFree.cc
nosql_lib/redis/src/RedisClientManager.cc
nosql_lib/redis/src/RedisConnection.cc
nosql_lib/redis/src/RedisResult.cc
nosql_lib/redis/src/RedisClientLockFree.cc
nosql_lib/redis/src/RedisClientManager.cc
nosql_lib/redis/src/RedisTransactionImpl.cc)
set(private_headers
${private_headers}
nosql_lib/redis/src/RedisClientImpl.h
nosql_lib/redis/src/RedisClientLockFree.h
nosql_lib/redis/src/RedisConnection.h
nosql_lib/redis/src/RedisTransactionImpl.h)

endif (Hiredis_FOUND)
endif (BUILD_REDIS)
Expand All @@ -385,9 +320,6 @@ if (NOT Hiredis_FOUND)
lib/src/RedisClientSkipped.cc
lib/src/RedisResultSkipped.cc
lib/src/RedisClientManagerSkipped.cc)
set(private_headers
${private_headers}
lib/src/RedisClientManager.h)
endif (NOT Hiredis_FOUND)

if (BUILD_TESTING)
Expand All @@ -401,14 +333,8 @@ find_package(OpenSSL)
if (OpenSSL_FOUND)
target_link_libraries(${PROJECT_NAME} PRIVATE OpenSSL::SSL OpenSSL::Crypto)
else (OpenSSL_FOUND)
set(DROGON_SOURCES
${DROGON_SOURCES}
lib/src/ssl_funcs/Md5.cc
set(DROGON_SOURCES ${DROGON_SOURCES} lib/src/ssl_funcs/Md5.cc
lib/src/ssl_funcs/Sha1.cc)
set(private_headers
${private_headers}
lib/src/ssl_funcs/Md5.h
lib/src/ssl_funcs/Sha1.h)
endif (OpenSSL_FOUND)

execute_process(COMMAND "git" rev-parse HEAD
Expand Down Expand Up @@ -457,57 +383,16 @@ set(DROGON_SOURCES
orm_lib/src/SqlBinder.cc
orm_lib/src/TransactionImpl.cc
orm_lib/src/RestfulController.cc)
set(DROGON_HEADERS
lib/inc/drogon/Attribute.h
lib/inc/drogon/CacheMap.h
lib/inc/drogon/Cookie.h
lib/inc/drogon/DrClassMap.h
lib/inc/drogon/DrObject.h
lib/inc/drogon/DrTemplate.h
lib/inc/drogon/DrTemplateBase.h
lib/inc/drogon/HttpAppFramework.h
lib/inc/drogon/HttpBinder.h
lib/inc/drogon/HttpClient.h
lib/inc/drogon/HttpController.h
lib/inc/drogon/HttpFilter.h
lib/inc/drogon/HttpRequest.h
lib/inc/drogon/HttpResponse.h
lib/inc/drogon/HttpSimpleController.h
lib/inc/drogon/HttpTypes.h
lib/inc/drogon/HttpViewData.h
lib/inc/drogon/IntranetIpFilter.h
lib/inc/drogon/IOThreadStorage.h
lib/inc/drogon/LocalHostFilter.h
lib/inc/drogon/MultiPart.h
lib/inc/drogon/NotFound.h
lib/inc/drogon/Session.h
lib/inc/drogon/UploadFile.h
lib/inc/drogon/WebSocketClient.h
lib/inc/drogon/WebSocketConnection.h
lib/inc/drogon/WebSocketController.h
lib/inc/drogon/drogon.h
lib/inc/drogon/version.h
lib/inc/drogon/drogon_callbacks.h
lib/inc/drogon/PubSubService.h
lib/inc/drogon/drogon_test.h
${CMAKE_CURRENT_BINARY_DIR}/exports/drogon/exports.h)
set(private_headers
${private_headers}
lib/src/DbClientManager.h
orm_lib/src/DbClientImpl.h
orm_lib/src/DbConnection.h
orm_lib/src/ResultImpl.h
orm_lib/src/TransactionImpl.h)
if (pg_FOUND OR MySQL_FOUND OR SQLite3_FOUND)
set(DROGON_SOURCES
${DROGON_SOURCES}
orm_lib/src/DbClientManager.cc)
else (pg_FOUND OR MySQL_FOUND OR SQLite3_FOUND)
set(DROGON_SOURCES
${DROGON_SOURCES}
lib/src/DbClientManagerSkipped.cc)
set(DROGON_SOURCES ${DROGON_SOURCES} lib/src/DbClientManagerSkipped.cc)
endif (pg_FOUND OR MySQL_FOUND OR SQLite3_FOUND)

target_sources(${PROJECT_NAME} PRIVATE ${DROGON_SOURCES})

set_target_properties(${PROJECT_NAME}
PROPERTIES CXX_STANDARD ${DROGON_CXX_STANDARD})
set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD_REQUIRED ON)
Expand Down Expand Up @@ -587,6 +472,40 @@ install(TARGETS ${PROJECT_NAME}
ARCHIVE DESTINATION "${INSTALL_LIB_DIR}" COMPONENT lib
LIBRARY DESTINATION "${INSTALL_LIB_DIR}" COMPONENT lib)

set(DROGON_HEADERS
lib/inc/drogon/Attribute.h
lib/inc/drogon/CacheMap.h
lib/inc/drogon/Cookie.h
lib/inc/drogon/DrClassMap.h
lib/inc/drogon/DrObject.h
lib/inc/drogon/DrTemplate.h
lib/inc/drogon/DrTemplateBase.h
lib/inc/drogon/HttpAppFramework.h
lib/inc/drogon/HttpBinder.h
lib/inc/drogon/HttpClient.h
lib/inc/drogon/HttpController.h
lib/inc/drogon/HttpFilter.h
lib/inc/drogon/HttpRequest.h
lib/inc/drogon/HttpResponse.h
lib/inc/drogon/HttpSimpleController.h
lib/inc/drogon/HttpTypes.h
lib/inc/drogon/HttpViewData.h
lib/inc/drogon/IntranetIpFilter.h
lib/inc/drogon/IOThreadStorage.h
lib/inc/drogon/LocalHostFilter.h
lib/inc/drogon/MultiPart.h
lib/inc/drogon/NotFound.h
lib/inc/drogon/Session.h
lib/inc/drogon/UploadFile.h
lib/inc/drogon/WebSocketClient.h
lib/inc/drogon/WebSocketConnection.h
lib/inc/drogon/WebSocketController.h
lib/inc/drogon/drogon.h
lib/inc/drogon/version.h
lib/inc/drogon/drogon_callbacks.h
lib/inc/drogon/PubSubService.h
lib/inc/drogon/drogon_test.h
${CMAKE_CURRENT_BINARY_DIR}/exports/drogon/exports.h)
install(FILES ${DROGON_HEADERS} DESTINATION ${INSTALL_INCLUDE_DIR}/drogon)

set(ORM_HEADERS
Expand All @@ -607,8 +526,7 @@ set(ORM_HEADERS
orm_lib/inc/drogon/orm/RestfulController.h)
install(FILES ${ORM_HEADERS} DESTINATION ${INSTALL_INCLUDE_DIR}/drogon/orm)

set(NOSQL_HEADERS
nosql_lib/redis/inc/drogon/nosql/RedisClient.h
set(NOSQL_HEADERS nosql_lib/redis/inc/drogon/nosql/RedisClient.h
nosql_lib/redis/inc/drogon/nosql/RedisResult.h
nosql_lib/redis/inc/drogon/nosql/RedisException.h)
install(FILES ${NOSQL_HEADERS} DESTINATION ${INSTALL_INCLUDE_DIR}/drogon/nosql)
Expand All @@ -625,32 +543,19 @@ set(DROGON_UTIL_HEADERS
install(FILES ${DROGON_UTIL_HEADERS}
DESTINATION ${INSTALL_INCLUDE_DIR}/drogon/utils)

set(DROGON_PLUGIN_HEADERS
lib/inc/drogon/plugins/Plugin.h
set(DROGON_PLUGIN_HEADERS lib/inc/drogon/plugins/Plugin.h
lib/inc/drogon/plugins/SecureSSLRedirector.h
lib/inc/drogon/plugins/AccessLogger.h)
install(FILES ${DROGON_PLUGIN_HEADERS}
DESTINATION ${INSTALL_INCLUDE_DIR}/drogon/plugins)

target_sources(${PROJECT_NAME} PRIVATE
${DROGON_SOURCES}
${private_headers}
${DROGON_HEADERS}
${ORM_HEADERS}
${DROGON_UTIL_HEADERS}
${DROGON_PLUGIN_HEADERS}
${NOSQL_HEADERS})

source_group("Public API"
FILES
${DROGON_HEADERS}
${ORM_HEADERS}
${DROGON_UTIL_HEADERS}
${DROGON_PLUGIN_HEADERS}
${NOSQL_HEADERS})
source_group("Private Headers"
FILES
${private_headers})

# Export the package for use from the build-tree (this registers the build-tree
# with a global cmake-registry) export(PACKAGE Drogon)
Expand Down Expand Up @@ -692,42 +597,3 @@ install(EXPORT DrogonTargets
NAMESPACE Drogon::
COMPONENT dev)

# Doxygen documentation
find_package(Doxygen OPTIONAL_COMPONENTS dot dia)
if(DOXYGEN_FOUND)
set(DOXYGEN_PROJECT_BRIEF "C++14/17-based HTTP application framework")
set(DOXYGEN_OUTPUT_DIRECTORY docs/${PROJECT_NAME})
set(DOXYGEN_GENERATE_LATEX NO)
set(DOXYGEN_BUILTIN_STL_SUPPORT YES)
set(DOXYGEN_USE_MDFILE_AS_MAINPAGE README.md)
set(DOXYGEN_STRIP_FROM_INC_PATH ${PROJECT_SOURCE_DIR}/lib/inc
${PROJECT_SOURCE_DIR}/orm_lib/inc
${CMAKE_CURRENT_BINARY_DIR}/exports)
set(DOXYGEN_EXAMPLE_PATTERNS *)
if(WIN32)
set(DOXYGEN_PREDEFINED _WIN32)
endif(WIN32)
doxygen_add_docs(doc_${PROJECT_NAME}
README.md
README.zh-CN.md
README.zh-TW.md
ChangeLog.md
CONTRIBUTING.md
${DROGON_HEADERS}
${DROGON_UTIL_HEADERS}
${DROGON_PLUGIN_HEADERS}
${ORM_HEADERS}
COMMENT "Generate documentation")
if(NOT TARGET doc)
add_custom_target(doc)
endif()
add_dependencies(doc doc_${PROJECT_NAME})
if (BUILD_DOC)
add_dependencies(${PROJECT_NAME} doc_${PROJECT_NAME})
# Don't install twice, so limit to Debug (assume developer)
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/docs/${PROJECT_NAME}
TYPE DOC
CONFIGURATIONS Debug)
endif(BUILD_DOC)
endif(DOXYGEN_FOUND)

1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

[![Build Status](https://travis-ci.com/an-tao/drogon.svg?branch=master)](https://travis-ci.com/an-tao/drogon)
![Build Status](https://github.com/an-tao/drogon/workflows/Build%20Drogon/badge.svg?branch=master)
[![Build status](https://ci.appveyor.com/api/projects/status/12ffuf6j5vankgyb/branch/master?svg=true)](https://ci.appveyor.com/project/an-tao/drogon/branch/master)
[![Total alerts](https://img.shields.io/lgtm/alerts/g/an-tao/drogon.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/an-tao/drogon/alerts/)
[![Join the chat at https://gitter.im/drogon-web/community](https://badges.gitter.im/drogon-web/community.svg)](https://gitter.im/drogon-web/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![Join the telegram group at https://t.me/joinchat/_mMNGv0748ZkMDAx](https://img.shields.io/badge/Telegram-2CA5E0?style=flat&logo=telegram&logoColor=white)](https://t.me/joinchat/_mMNGv0748ZkMDAx)
Expand Down
1 change: 1 addition & 0 deletions README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

[![Build Status](https://travis-ci.com/an-tao/drogon.svg?branch=master)](https://travis-ci.com/an-tao/drogon)
![Build Status](https://github.com/an-tao/drogon/workflows/Build%20Drogon/badge.svg?branch=master)
[![Build status](https://ci.appveyor.com/api/projects/status/12ffuf6j5vankgyb/branch/master?svg=true)](https://ci.appveyor.com/project/an-tao/drogon/branch/master)
[![Total alerts](https://img.shields.io/lgtm/alerts/g/an-tao/drogon.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/an-tao/drogon/alerts/)
[![Join the chat at https://gitter.im/drogon-web/community](https://badges.gitter.im/drogon-web/community.svg)](https://gitter.im/drogon-web/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![Join the telegram group at https://t.me/joinchat/_mMNGv0748ZkMDAx](https://img.shields.io/badge/Telegram-2CA5E0?style=flat&logo=telegram&logoColor=white)](https://t.me/joinchat/_mMNGv0748ZkMDAx)
Expand Down
1 change: 1 addition & 0 deletions README.zh-TW.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

[![Build Status](https://travis-ci.com/an-tao/drogon.svg?branch=master)](https://travis-ci.com/an-tao/drogon)
![Build Status](https://github.com/an-tao/drogon/workflows/Build%20Drogon/badge.svg?branch=master)
[![Build status](https://ci.appveyor.com/api/projects/status/12ffuf6j5vankgyb/branch/master?svg=true)](https://ci.appveyor.com/project/an-tao/drogon/branch/master)
[![Total alerts](https://img.shields.io/lgtm/alerts/g/an-tao/drogon.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/an-tao/drogon/alerts/)
[![Join the chat at https://gitter.im/drogon-web/community](https://badges.gitter.im/drogon-web/community.svg)](https://gitter.im/drogon-web/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![Join the telegram group at https://t.me/joinchat/_mMNGv0748ZkMDAx](https://img.shields.io/badge/Telegram-2CA5E0?style=flat&logo=telegram&logoColor=white)](https://t.me/joinchat/_mMNGv0748ZkMDAx)
Expand Down
1 change: 0 additions & 1 deletion cmake/templates/DrogonConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ get_filename_component(DROGON_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
if(NOT TARGET Drogon::Drogon)
include("${DROGON_CMAKE_DIR}/DrogonTargets.cmake")
include("${DROGON_CMAKE_DIR}/DrogonUtilities.cmake")
include("${DROGON_CMAKE_DIR}/ParseAndAddDrogonTests.cmake")
endif()

get_target_property(DROGON_INCLUDE_DIRS Drogon::Drogon INTERFACE_INCLUDE_DIRECTORIES)
Expand Down
Loading

0 comments on commit a2e1190

Please sign in to comment.