mirror of
https://github.com/drogonframework/drogon.git
synced 2025-07-17 00:00:35 -04:00
Compare commits
9 Commits
58055ae39c
...
366311c196
Author | SHA1 | Date | |
---|---|---|---|
|
366311c196 | ||
|
5df9b48998 | ||
|
8d4c17702a | ||
|
9337571e1a | ||
|
816684e15d | ||
|
40aa034595 | ||
|
de4c811772 | ||
|
3ecb8b4917 | ||
|
f761c54aa8 |
11
.github/dependabot.yml
vendored
Normal file
11
.github/dependabot.yml
vendored
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
# To get started with Dependabot version updates, you'll need to specify which
|
||||||
|
# package ecosystems to update and where the package manifests are located.
|
||||||
|
# Please see the documentation for all configuration options:
|
||||||
|
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
|
||||||
|
|
||||||
|
version: 2
|
||||||
|
updates:
|
||||||
|
- package-ecosystem: "github-actions"
|
||||||
|
directory: "/"
|
||||||
|
schedule:
|
||||||
|
interval: "monthly"
|
217
.github/workflows/cmake.yml
vendored
217
.github/workflows/cmake.yml
vendored
@ -1,8 +1,8 @@
|
|||||||
name: Build Drogon
|
name: Build & Test
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [ master ]
|
branches: [master]
|
||||||
pull_request:
|
pull_request:
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
@ -21,10 +21,10 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
link: [ 'STATIC', 'SHARED' ]
|
link: ["STATIC", "SHARED"]
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout Drogon source code
|
- name: Checkout Drogon source code
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
submodules: true
|
submodules: true
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
@ -64,124 +64,123 @@ jobs:
|
|||||||
shell: bash
|
shell: bash
|
||||||
run: ./test.sh -w
|
run: ./test.sh -w
|
||||||
|
|
||||||
unix:
|
macos:
|
||||||
|
name: macos/clang
|
||||||
|
runs-on: macos-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout Drogon source code
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
submodules: true
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
# Already installed: brotli, zlib, postgresql@14, lz4, sqlite3
|
||||||
|
run: brew install ninja jsoncpp mariadb hiredis redis
|
||||||
|
|
||||||
|
- name: Create Build Environment & Configure Cmake
|
||||||
|
# Some projects don't allow in-source building, so create a separate build directory
|
||||||
|
# We'll use this as our working directory for all subsequent commands
|
||||||
|
run: |
|
||||||
|
cmake -B build -G Ninja \
|
||||||
|
-DCMAKE_BUILD_TYPE=$BUILD_TYPE \
|
||||||
|
-DBUILD_TESTING=on \
|
||||||
|
-DBUILD_SHARED_LIBS=OFF
|
||||||
|
|
||||||
|
- name: Build
|
||||||
|
working-directory: ./build
|
||||||
|
# Execute the build. You can specify a specific target with "--target <NAME>"
|
||||||
|
run: ninja && sudo ninja install
|
||||||
|
|
||||||
|
- name: Prepare for testing
|
||||||
|
run: |
|
||||||
|
brew tap homebrew/services
|
||||||
|
brew services restart postgresql@14
|
||||||
|
brew services start mariadb
|
||||||
|
brew services start redis
|
||||||
|
sleep 4
|
||||||
|
mariadb -e "SET PASSWORD FOR 'root'@'localhost' = PASSWORD('')"
|
||||||
|
mariadb -e "GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost'"
|
||||||
|
mariadb -e "FLUSH PRIVILEGES"
|
||||||
|
brew services restart mariadb
|
||||||
|
sleep 4
|
||||||
|
psql -c 'create user postgres superuser;' postgres
|
||||||
|
|
||||||
|
- name: Test
|
||||||
|
# Execute tests defined by the CMake configuration.
|
||||||
|
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
|
||||||
|
run: ./test.sh -t
|
||||||
|
|
||||||
|
ubuntu:
|
||||||
name: ${{ matrix.buildname }}
|
name: ${{ matrix.buildname }}
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ubuntu-22.04
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
- os: ubuntu-22.04
|
- buildname: "ubuntu-22.04/gcc"
|
||||||
buildname: 'ubuntu-22.04/gcc'
|
|
||||||
link: SHARED
|
link: SHARED
|
||||||
triplet: x64-linux
|
- buildname: "ubuntu-22.04/gcc"
|
||||||
compiler: gcc_64
|
|
||||||
- os: ubuntu-22.04
|
|
||||||
buildname: 'ubuntu-22.04/gcc'
|
|
||||||
link: STATIC
|
link: STATIC
|
||||||
triplet: x64-linux
|
- buildname: "ubuntu-22.04/coroutines"
|
||||||
compiler: gcc_64
|
|
||||||
- os: ubuntu-22.04
|
|
||||||
buildname: 'ubuntu-22.04/gcc-10'
|
|
||||||
link: STATIC
|
link: STATIC
|
||||||
triplet: x64-linux
|
|
||||||
- os: macos-latest
|
|
||||||
buildname: 'macos/clang'
|
|
||||||
link: STATIC
|
|
||||||
triplet: x64-osx
|
|
||||||
compiler: clang_64
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout Drogon source code
|
- name: Checkout Drogon source code
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
submodules: true
|
submodules: true
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
- name: (macOS) Install dependencies
|
- name: Install dependencies
|
||||||
if: runner.os == 'macOS'
|
run: |
|
||||||
# Already installed: brotli, zlib, postgresql@14, lz4, sqlite3
|
# Installing packages might fail as the github image becomes outdated
|
||||||
run: brew install jsoncpp mariadb hiredis redis
|
sudo apt update
|
||||||
|
# These aren't available or don't work well in vcpkg
|
||||||
|
sudo apt-get install -y libjsoncpp-dev uuid-dev libssl-dev zlib1g-dev libsqlite3-dev
|
||||||
|
sudo apt-get install -y ninja-build libbrotli-dev
|
||||||
|
|
||||||
- name: (Linux) Install dependencies
|
- name: Install postgresql
|
||||||
if: runner.os == 'Linux'
|
run: |
|
||||||
run: |
|
sudo apt-get --purge remove postgresql postgresql-doc postgresql-common postgresql-client-common
|
||||||
# Installing packages might fail as the github image becomes outdated
|
sudo apt-get -y install postgresql-all
|
||||||
sudo apt update
|
|
||||||
# These aren't available or don't work well in vcpkg
|
|
||||||
sudo apt-get install -y libjsoncpp-dev uuid-dev libssl-dev zlib1g-dev libsqlite3-dev
|
|
||||||
sudo apt-get install -y libbrotli-dev
|
|
||||||
- name: (Linux) Install gcc-10
|
|
||||||
if: matrix.buildname == 'ubuntu-22.04/gcc-10'
|
|
||||||
run: sudo apt-get install -y gcc-10 g++-10
|
|
||||||
|
|
||||||
- name: (Linux) Install postgresql
|
- name: Export `shared`
|
||||||
if: matrix.os == 'ubuntu-22.04'
|
run: |
|
||||||
run: |
|
[[ ${{ matrix.link }} == "SHARED" ]] && shared="ON" || shared="OFF"
|
||||||
sudo apt-get --purge remove postgresql postgresql-doc postgresql-common postgresql-client-common
|
echo "shared=$shared" >> $GITHUB_ENV
|
||||||
sudo apt-get -y install postgresql-all
|
|
||||||
- name: Export `shared`
|
|
||||||
run: |
|
|
||||||
[[ ${{ matrix.link }} == "SHARED" ]] && shared="ON" || shared="OFF"
|
|
||||||
echo "shared=$shared" >> $GITHUB_ENV
|
|
||||||
|
|
||||||
- name: Create Build Environment & Configure Cmake
|
- name: Create Build Environment & Configure Cmake
|
||||||
# Some projects don't allow in-source building, so create a separate build directory
|
# Some projects don't allow in-source building, so create a separate build directory
|
||||||
# We'll use this as our working directory for all subsequent commands
|
# We'll use this as our working directory for all subsequent commands
|
||||||
if: matrix.buildname != 'ubuntu-22.04/gcc-10'
|
if: matrix.buildname != 'ubuntu-22.04/coroutines'
|
||||||
run: |
|
run: |
|
||||||
cmake -B build \
|
cmake -B build -G Ninja \
|
||||||
-DCMAKE_BUILD_TYPE=$BUILD_TYPE \
|
-DCMAKE_BUILD_TYPE=$BUILD_TYPE \
|
||||||
-DBUILD_TESTING=on \
|
-DBUILD_TESTING=on \
|
||||||
-DBUILD_SHARED_LIBS=$shared
|
-DBUILD_SHARED_LIBS=$shared
|
||||||
|
- name: Create Build Environment & Configure Cmake (coroutines)
|
||||||
|
# Some projects don't allow in-source building, so create a separate build directory
|
||||||
|
# We'll use this as our working directory for all subsequent commands
|
||||||
|
if: matrix.buildname == 'ubuntu-22.04/coroutines'
|
||||||
|
run: |
|
||||||
|
cmake -B build -G Ninja \
|
||||||
|
-DCMAKE_BUILD_TYPE=$BUILD_TYPE \
|
||||||
|
-DBUILD_TESTING=on \
|
||||||
|
-DCMAKE_CXX_FLAGS="-fcoroutines" \
|
||||||
|
-DBUILD_SHARED_LIBS=$shared
|
||||||
|
|
||||||
- name: Create Build Environment & Configure Cmake (gcc-10)
|
- name: Build
|
||||||
# Some projects don't allow in-source building, so create a separate build directory
|
working-directory: ./build
|
||||||
# We'll use this as our working directory for all subsequent commands
|
# Execute the build. You can specify a specific target with "--target <NAME>"
|
||||||
if: matrix.buildname == 'ubuntu-22.04/gcc-10'
|
run: ninja && sudo ninja install
|
||||||
run: |
|
|
||||||
cmake -B build \
|
|
||||||
-DCMAKE_BUILD_TYPE=$BUILD_TYPE \
|
|
||||||
-DBUILD_TESTING=on \
|
|
||||||
-DCMAKE_CXX_FLAGS="-fcoroutines" \
|
|
||||||
-DBUILD_SHARED_LIBS=$shared
|
|
||||||
env:
|
|
||||||
CC: gcc-10
|
|
||||||
CXX: g++-10
|
|
||||||
|
|
||||||
- name: Build
|
- name: Prepare for testing
|
||||||
working-directory: ./build
|
run: |
|
||||||
# Execute the build. You can specify a specific target with "--target <NAME>"
|
sudo systemctl start postgresql
|
||||||
run: make -j $(nproc) && sudo make install
|
sleep 1
|
||||||
|
sudo -u postgres psql -c "ALTER USER postgres WITH PASSWORD '12345'" postgres
|
||||||
|
|
||||||
- name: (macOS) Prepare for testing
|
- name: Test
|
||||||
if: runner.os == 'macOS'
|
# Execute tests defined by the CMake configuration.
|
||||||
run: |
|
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
|
||||||
brew tap homebrew/services
|
run: ./test.sh -t
|
||||||
brew services restart postgresql@14
|
|
||||||
brew services start mariadb
|
|
||||||
brew services start redis
|
|
||||||
sleep 4
|
|
||||||
mariadb -e "SET PASSWORD FOR 'root'@'localhost' = PASSWORD('')"
|
|
||||||
mariadb -e "GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost'"
|
|
||||||
mariadb -e "FLUSH PRIVILEGES"
|
|
||||||
brew services restart mariadb
|
|
||||||
sleep 4
|
|
||||||
psql -c 'create user postgres superuser;' postgres
|
|
||||||
|
|
||||||
- name: (Linux) Prepare for testing
|
|
||||||
if: runner.os == 'Linux'
|
|
||||||
run: |
|
|
||||||
sudo systemctl start postgresql
|
|
||||||
sleep 1
|
|
||||||
sudo -u postgres psql -c "ALTER USER postgres WITH PASSWORD '12345'" postgres
|
|
||||||
|
|
||||||
- name: Test
|
|
||||||
# Execute tests defined by the CMake configuration.
|
|
||||||
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
|
|
||||||
run: ./test.sh -t
|
|
||||||
|
|
||||||
- name: Lint
|
|
||||||
if: matrix.os == 'ubuntu-22.04'
|
|
||||||
run: |
|
|
||||||
sudo apt install -y dos2unix
|
|
||||||
./format.sh && git diff --exit-code
|
|
||||||
|
14
.github/workflows/codeql.yml
vendored
14
.github/workflows/codeql.yml
vendored
@ -9,6 +9,10 @@ on:
|
|||||||
schedule:
|
schedule:
|
||||||
- cron: '46 7 * * 5'
|
- cron: '46 7 * * 5'
|
||||||
|
|
||||||
|
concurrency:
|
||||||
|
group: ${{ github.workflow }}-${{ github.ref }}
|
||||||
|
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
|
||||||
|
|
||||||
env:
|
env:
|
||||||
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
|
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
|
||||||
BUILD_TYPE: Release
|
BUILD_TYPE: Release
|
||||||
@ -36,7 +40,7 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout Drogon source code
|
- name: Checkout Drogon source code
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
submodules: true
|
submodules: true
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
@ -45,13 +49,13 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
sudo apt update
|
sudo apt update
|
||||||
sudo apt-get install -y libjsoncpp-dev uuid-dev libssl-dev zlib1g-dev libsqlite3-dev
|
sudo apt-get install -y libjsoncpp-dev uuid-dev libssl-dev zlib1g-dev libsqlite3-dev
|
||||||
sudo apt-get install -y libbrotli-dev
|
sudo apt-get install -y ninja-build libbrotli-dev
|
||||||
|
|
||||||
- name: Create Build Environment & Configure Cmake
|
- name: Create Build Environment & Configure Cmake
|
||||||
run: |
|
run: |
|
||||||
cmake -B build \
|
cmake -B build -G Ninja \
|
||||||
-DCMAKE_BUILD_TYPE=$BUILD_TYPE \
|
-DCMAKE_BUILD_TYPE=$BUILD_TYPE \
|
||||||
-DBUILD_TESTING=on \
|
-DBUILD_TESTING=on \
|
||||||
-DBUILD_SHARED_LIBS=$SHARED
|
-DBUILD_SHARED_LIBS=$SHARED
|
||||||
|
|
||||||
# Initializes the CodeQL tools for scanning.
|
# Initializes the CodeQL tools for scanning.
|
||||||
@ -68,7 +72,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
working-directory: ./build
|
working-directory: ./build
|
||||||
run: make -j $(nproc) && sudo make install
|
run: ninja && sudo ninja install
|
||||||
|
|
||||||
- name: Perform CodeQL Analysis
|
- name: Perform CodeQL Analysis
|
||||||
uses: github/codeql-action/analyze@v2
|
uses: github/codeql-action/analyze@v2
|
||||||
|
21
.github/workflows/cpp.yml
vendored
Normal file
21
.github/workflows/cpp.yml
vendored
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
name: C++
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [master]
|
||||||
|
pull_request:
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
format:
|
||||||
|
runs-on: ubuntu-22.04
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Install dos2unix
|
||||||
|
run: sudo apt-get install -y dos2unix
|
||||||
|
|
||||||
|
- name: Check formatting
|
||||||
|
run: ./format.sh && git diff --exit-code
|
@ -1,7 +1,7 @@
|
|||||||
#include <drogon/drogon.h>
|
#include <drogon/drogon.h>
|
||||||
int main() {
|
int main() {
|
||||||
//Set HTTP listener address and port
|
//Set HTTP listener address and port
|
||||||
drogon::app().addListener("0.0.0.0",80);
|
drogon::app().addListener("0.0.0.0", 5555);
|
||||||
//Load config file
|
//Load config file
|
||||||
//drogon::app().loadConfigFile("../config.json");
|
//drogon::app().loadConfigFile("../config.json");
|
||||||
//drogon::app().loadConfigFile("../config.yaml");
|
//drogon::app().loadConfigFile("../config.yaml");
|
||||||
|
@ -508,7 +508,7 @@ if(@@.get<std::string>("rdbms")=="postgresql")
|
|||||||
if(@@.get<std::string>("rdbms")=="postgresql")
|
if(@@.get<std::string>("rdbms")=="postgresql")
|
||||||
{
|
{
|
||||||
%>
|
%>
|
||||||
n = sprintf(placeholderStr,"$%d,",placeholder++);
|
n = snprintf(placeholderStr,sizeof(placeholderStr),"$%d,",placeholder++);
|
||||||
sql.append(placeholderStr, n);
|
sql.append(placeholderStr, n);
|
||||||
<%c++
|
<%c++
|
||||||
}else
|
}else
|
||||||
|
@ -352,43 +352,67 @@ class Users
|
|||||||
size_t n = 0;
|
size_t n = 0;
|
||||||
if (dirtyFlag_[0])
|
if (dirtyFlag_[0])
|
||||||
{
|
{
|
||||||
n = sprintf(placeholderStr, "$%d,", placeholder++);
|
n = snprintf(placeholderStr,
|
||||||
|
sizeof(placeholderStr),
|
||||||
|
"$%d,",
|
||||||
|
placeholder++);
|
||||||
sql.append(placeholderStr, n);
|
sql.append(placeholderStr, n);
|
||||||
}
|
}
|
||||||
if (dirtyFlag_[1])
|
if (dirtyFlag_[1])
|
||||||
{
|
{
|
||||||
n = sprintf(placeholderStr, "$%d,", placeholder++);
|
n = snprintf(placeholderStr,
|
||||||
|
sizeof(placeholderStr),
|
||||||
|
"$%d,",
|
||||||
|
placeholder++);
|
||||||
sql.append(placeholderStr, n);
|
sql.append(placeholderStr, n);
|
||||||
}
|
}
|
||||||
if (dirtyFlag_[2])
|
if (dirtyFlag_[2])
|
||||||
{
|
{
|
||||||
n = sprintf(placeholderStr, "$%d,", placeholder++);
|
n = snprintf(placeholderStr,
|
||||||
|
sizeof(placeholderStr),
|
||||||
|
"$%d,",
|
||||||
|
placeholder++);
|
||||||
sql.append(placeholderStr, n);
|
sql.append(placeholderStr, n);
|
||||||
}
|
}
|
||||||
if (dirtyFlag_[3])
|
if (dirtyFlag_[3])
|
||||||
{
|
{
|
||||||
n = sprintf(placeholderStr, "$%d,", placeholder++);
|
n = snprintf(placeholderStr,
|
||||||
|
sizeof(placeholderStr),
|
||||||
|
"$%d,",
|
||||||
|
placeholder++);
|
||||||
sql.append(placeholderStr, n);
|
sql.append(placeholderStr, n);
|
||||||
}
|
}
|
||||||
if (dirtyFlag_[4])
|
if (dirtyFlag_[4])
|
||||||
{
|
{
|
||||||
n = sprintf(placeholderStr, "$%d,", placeholder++);
|
n = snprintf(placeholderStr,
|
||||||
|
sizeof(placeholderStr),
|
||||||
|
"$%d,",
|
||||||
|
placeholder++);
|
||||||
sql.append(placeholderStr, n);
|
sql.append(placeholderStr, n);
|
||||||
}
|
}
|
||||||
if (dirtyFlag_[5])
|
if (dirtyFlag_[5])
|
||||||
{
|
{
|
||||||
n = sprintf(placeholderStr, "$%d,", placeholder++);
|
n = snprintf(placeholderStr,
|
||||||
|
sizeof(placeholderStr),
|
||||||
|
"$%d,",
|
||||||
|
placeholder++);
|
||||||
sql.append(placeholderStr, n);
|
sql.append(placeholderStr, n);
|
||||||
}
|
}
|
||||||
sql += "default,";
|
sql += "default,";
|
||||||
if (dirtyFlag_[7])
|
if (dirtyFlag_[7])
|
||||||
{
|
{
|
||||||
n = sprintf(placeholderStr, "$%d,", placeholder++);
|
n = snprintf(placeholderStr,
|
||||||
|
sizeof(placeholderStr),
|
||||||
|
"$%d,",
|
||||||
|
placeholder++);
|
||||||
sql.append(placeholderStr, n);
|
sql.append(placeholderStr, n);
|
||||||
}
|
}
|
||||||
if (dirtyFlag_[8])
|
if (dirtyFlag_[8])
|
||||||
{
|
{
|
||||||
n = sprintf(placeholderStr, "$%d,", placeholder++);
|
n = snprintf(placeholderStr,
|
||||||
|
sizeof(placeholderStr),
|
||||||
|
"$%d,",
|
||||||
|
placeholder++);
|
||||||
sql.append(placeholderStr, n);
|
sql.append(placeholderStr, n);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
Loading…
x
Reference in New Issue
Block a user