drogonframework / drogon Goto Github PK
View Code? Open in Web Editor NEWDrogon: A C++14/17/20 based HTTP web application framework running on Linux/macOS/Unix/Windows
License: MIT License
Drogon: A C++14/17/20 based HTTP web application framework running on Linux/macOS/Unix/Windows
License: MIT License
目前的獲取提交的數據的方法,有 get, post,
但是在 post 方法下, 使用 from 提交可以拿到值,但是使用 post/body 方式提交的,則無法獲取到值
如果使用 request->getJsonObject();
拿到的是一個空指針, 不知道是我獲取的方式問題,還是框架目前不支持 body 方式?
Hi
I'm looking at the examples code and your recommendations of using controllers by inheriting from HttpSimpleController<>
or HttpController<>
. This is nice, but how do you initialize them? How do I provide custom constructor to inject other objects or set up some initial values in such controllers?
For instance, in this example: https://github.com/an-tao/drogon/blob/master/examples/simple_example/main.cc#L62
How would I provide non-default constructor and how should I call it?
From the code it seems to me that only default contractors are called: https://github.com/an-tao/drogon/blob/master/lib/inc/drogon/DrObject.h#L79
For now I can only see that one would have to use static global objects and variables to customize the controllers?
Hello @an-tao
Thank you for your greate work .
I see your benchmark result at : https://github.com/an-tao/drogon/wiki/benchmarks . Could you compare with other framework too ?
Thank you
Describe the bug
load 配置文件时, 如果我在配置文件当中:
To Reproduce
Steps to reproduce the behavior:
Expected behavior
应该是跳过无效的项吧。。。
Desktop (please complete the following information):
Additional context
建议先过滤掉空的,或无效的json配置,
How to use std::regex to find the right controller without using a loop?
https://github.com/an-tao/drogon/blob/f5c97d33cdf36e2b05fb7c49d7d9eb5ae2bbb268/lib/src/HttpControllersRouter.cc#L218-L234
目前的 model 是自动生成的, 生成之后,如果有代码变动的情况下
为了不破坏原有的结构
目前我这边是写的新的一几个东西, 不知道,这些,做者是怎么考量的。
Do you have any plan to support windows ?
Describe the bug
sqlite3 connection is not excuting any query if previous contains error.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
when error, reset the connection or create a new one. the next query should not be blocked forever.
Versions:
INSERT SQL: INSERT INTO provinces (seq, name, note) VALUES ('11', '11', '11')
Insert id = 0, affectedRows = 1
我在 drogon/orm/Result.h 这个文件查的方法, insretId() 方法需要特别使用?
Is your feature request related to a problem? Please describe.
JsonCpp has some loose typing
example If we try to get int from a value and its not present it return 0.
Describe the solution you'd like
change to nlohmann/json, its strict typing. dont allow unproper things. well designed library. its api is almost same as jsoncpp. its also fast then jsoncpp and we need some less code to type and its very well documented and more features.
i think existing users can change to nlohmann/json very easily.its header only library. json.hpp is the single required file.
If drogon is included as a sub-module in other project, this line overwrites top level CMAKE_MODULE_PATH which will add drogon/cmake_modules to its own CMAKE_MODULE_PATH.
https://github.com/an-tao/drogon/blob/8d251f8158c77283a2ba87d5c9f12ce63af3ea99/CMakeLists.txt#L28
I think this line would be better if it was replaced with the following?
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake_modules/)
or
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake_modules/)
I can run multiple Drogon apps using the same port.
Expected behavior
Port in use error
Describe the bug
CMakeLists.txt 关于jsoncpp定位的问题
To Reproduce
Steps to reproduce the behavior:
Expected behavior
判断位置: /usr/include/json/version.h
实际位置: /usr/include/jsoncpp/json/version
Desktop (please complete the following information):
Additional context
不知道别的系统是不是这个问题,
目前的解决办法:
安装之前:
如果提示json太老,
莫非是我的系统的问题? 不知道 linuxmit 是不是都是这个样子
Describe the bug
Created a container and shared a volume to be able to develop locally since I am on Windows. Encountered compilation errors on a fresh install.
To Reproduce
Steps to reproduce the behavior:
cd $WORK_PATH
git clone https://github.com/an-tao/drogon
cd drogon
git submodule update --init
mkdir build
cd build
cmake ..
Expected behavior
Successful Compilation
Screenshots
If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
Additional context
Dockerfile
FROM ubuntu:18.04
RUN apt-get update -yqq \
&& apt-get install -yqq --no-install-recommends software-properties-common \
sudo curl wget cmake locales git gcc-8 g++-8 \
openssl libssl-dev libjsoncpp-dev uuid-dev zlib1g-dev \
postgresql-server-dev-all libmariadbclient-dev libsqlite3-dev \
&& rm -rf /var/lib/apt/lists/* \
&& locale-gen en_US.UTF-8
ENV LANG=en_US.UTF-8 \
LANGUAGE=en_US:en \
LC_ALL=en_US.UTF-8 \
CC=gcc-8 \
CXX=g++-8 \
AR=gcc-ar-8 \
RANLIB=gcc-ranlib-8 \
IROOT=/install
Also tried to run ./build.sh
to the same following error:
CMakeOutput.log
https://pastebin.com/EntKKUsZ
DbClient能否提供prepare stmt的支持?
I'd like to know what's the recommended way to access pivot tables and related records with the ORM, if there is one and if not the recommended way of doing so in the most performant way as intended by drogon.
Describe the bug
I'm trying to build a release version of drogon
but I keep getting this:
[ 51%] Linking CXX executable multiple_ws_test
/usr/bin/ld: ../libdrogon.a(Utilities.cc.o): undefined reference to symbol 'inflateEnd'
//lib/x86_64-linux-gnu/libz.so.1: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
examples/CMakeFiles/multiple_ws_test.dir/build.make:104: recipe for target 'examples/multiple_ws_test' failed
make[2]: *** [examples/multiple_ws_test] Error 1
CMakeFiles/Makefile2:223: recipe for target 'examples/CMakeFiles/multiple_ws_test.dir/all' failed
make[1]: *** [examples/CMakeFiles/multiple_ws_test.dir/all] Error 2
Makefile:129: recipe for target 'all' failed
make: *** [all] Error 2
Steps to reproduce
cd $WORK_PATH
git clone https://github.com/an-tao/drogon
cd drogon
git submodule update --init
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release ..
make
OS | (WSL) Ubuntu 18.04.3 LTS |
Kernel | 4.4.0-18362-Microsoft |
Processor | 64-bit |
Lib | Version |
---|---|
cmake | 3.10.2 |
gcc | 7.4.0 |
libjsoncpp-dev | 1.7.4-3 |
openssl | 1.1.1 |
libssl-dev | 1.1.1 |
zlib1g-dev | 1.2.11 |
libboost-all-dev | 1.65.1 |
Lib | Version |
---|---|
postgresql-all | 10+190 |
postgresql-server-dev-all | 190 |
libmariadbclient-dev | 10.1.41 |
libsqlite3-dev | 3.22.0 |
When compiling, g++ reports that the atomic library is missing in drogon_ctl, _drogon_ctl and all the examples. This likely only happens for c++14 builds.
[53%] Linking CXX executable drogon_ctl
/usr/bin/ld: ../libdrogon.a(HttpAppFrameworkImpl.cc.o): in function `drogon::HttpAppFrameworkImpl::onConnection(std::shared_ptr<trantor::TcpConnection> const&)':
HttpAppFrameworkImpl.cc:(.text+0x2b00): undefined reference to `__atomic_load_8'
/usr/bin/ld: HttpAppFrameworkImpl.cc:(.text+0x2bac): undefined reference to `__atomic_fetch_add_8'
/usr/bin/ld: ../libdrogon.a(HttpAppFrameworkImpl.cc.o): in function `std::__atomic_base<long long>::operator--(int)':
HttpAppFrameworkImpl.cc:(.text._ZNSt13__atomic_baseIxEmmEi[_ZNSt13__atomic_baseIxEmmEi]+0x40): undefined reference to `__atomic_fetch_sub_8'
/usr/bin/ld: ../trantor/libtrantor.a(Timer.cc.o): in function `std::__atomic_base<unsigned long long>::operator++()':
Timer.cc:(.text._ZNSt13__atomic_baseIyEppEv[_ZNSt13__atomic_baseIyEppEv]+0x28): undefined reference to `__atomic_fetch_add_8'
collect2: error: ld returned 1 exit status
make[2]: *** [drogon_ctl/CMakeFiles/drogon_ctl.dir/build.make:499: drogon_ctl/drogon_ctl] Error 1
make[1]: *** [CMakeFiles/Makefile2:518: drogon_ctl/CMakeFiles/drogon_ctl.dir/all] Error 2
To fix
add target_link_libraries(drogon_ctl PUBLIC atomic)
to drogon_ctl/CMakeLists.txt
and to each of the examples.
Environment:
drogon/lib/src/Utilities.cc
is_base64 这个方法,也其他的不对照出啊, 这个是 小写_小写, 这样样式的,其他的都是 小写大写 样式的.
另外,是否考虑,工具类,这一块,分为几个文件,几个类,每个类有各自的类型的工作处理函数
Thanks for creating this wonderful project. I am now integrating it with my own project.
Please create tagged version, e.g. 0.1.0, and changelog so that dependent projects (e.g. mine) can choose which tagged version they prefer to use. The dependencies, e.g. Trantor, should also be tagged similarly.
I wonder how to differentiate between two WebSocketConnectionPtr
? Is there some unique id that I can use to check if two WebSocketConnectionPtr
represent same actual connection, or two different connections?
I cant find a way to get websocket connection headers. For example whey I connect using browser, the following request headers are sent to drogon.
Host: 127.0.0.1:8848
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:66.0) Gecko/20100101 Firefox/66.0
Accept: */*
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Sec-WebSocket-Version: 13
Origin: http://127.0.0.1:9100
Sec-WebSocket-Extensions: permessage-deflate
Sec-WebSocket-Key: wXg3wPvLUZNJklC5+uuMrQ==
Connection: keep-alive, Upgrade
Pragma: no-cache
Cache-Control: no-cache
Upgrade: websocket
How do I access them? For example how to get value of Sec-WebSocket-Key
? I found that ppl use Sec-WebSocket-Key
as a way to identify and compare web-socket connection.
METHOD_ADD(User::login,"/token?userId={1}&passwd={2}",Post);
when i pass "foo bar" to the userId, I only get "foo" in the function.
Install directory is currently hard code to /usr/local
. Please let users specify their preferred location via the CMAKE_INSTALL_PREFIX
variable.
fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Access-Control-Allow-Origin': '*',
},
body: JSON.stringify(json)
})
My handler method is :
METHOD_ADD(User::newForm,"/accessory?materialId={1}&slug={2}&name={3}",Post,Options);
but the request from browser has been blocked by CORS policy.
Please Help
Describe the bug
Build errors with orm generated files on debian 9.
To Reproduce
Steps to reproduce the behavior:
Scanning dependencies of target hempeno
[ 3%] Building CXX object CMakeFiles/hempeno.dir/models/Brands.cc.o
In file included from /usr/include/c++/6/bits/shared_ptr.h:52:0,
from /usr/include/c++/6/memory:82,
from /usr/local/include/drogon/orm/Result.h:20,
from /var/www/html/hempeno/hempeno/models/Brands.h:9,
from /var/www/html/hempeno/hempeno/models/Brands.cc:8:
/usr/include/c++/6/bits/shared_ptr_base.h: In instantiation of ‘std::__shared_ptr<_Tp, _Lp>& std::__shared_ptr<_Tp, _Lp>::operator=(std::__shared_ptr<_Tp1, _Lp>&&) [with _Tp1 = long unsigned int; _Tp = long int; __gnu_cxx::_Lock_policy _Lp = (__gnu_cxx::_Lock_policy)2u]’:
/usr/include/c++/6/bits/shared_ptr.h:302:4: required from ‘std::shared_ptr<_Tp>& std::shared_ptr<_Tp>::operator=(std::shared_ptr<_Tp1>&&) [with _Tp1 = long unsigned int; _Tp = long int]’
/var/www/html/hempeno/hempeno/models/Brands.cc:112:40: required from here
/usr/include/c++/6/bits/shared_ptr_base.h:1011:4: error: no matching function for call to ‘std::__shared_ptr<long int, (__gnu_cxx::_Lock_policy)2u>::__shared_ptr(std::remove_reference<std::__shared_ptr<long unsigned int, (__gnu_cxx::_Lock_policy)2u>&>::type)’
__shared_ptr(std::move(__r)).swap(*this);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/6/bits/shared_ptr_base.h:1149:7: note: candidate: std::__shared_ptr<_Tp, _Lp>::__shared_ptr(const std::__weak_ptr<_Tp, _Lp>&, std::nothrow_t) [with _Tp = long int; __gnu_cxx::_Lock_policy _Lp = (__gnu_cxx::_Lock_policy)2u]
__shared_ptr(const __weak_ptr<_Tp, _Lp>& __r, std::nothrow_t)
^~~~~~~~~~~~
/usr/include/c++/6/bits/shared_ptr_base.h:1149:7: note: candidate expects 2 arguments, 1 provided
/usr/include/c++/6/bits/shared_ptr_base.h:1097:2: note: candidate: template<class _Alloc, class ... _Args> std::__shared_ptr<_Tp, _Lp>::__shared_ptr(std::_Sp_make_shared_tag, const _Alloc&, _Args&& ...)
__shared_ptr(_Sp_make_shared_tag __tag, const _Alloc& __a,
^~~~~~~~~~~~
/usr/include/c++/6/bits/shared_ptr_base.h:1097:2: note: template argument deduction/substitution failed:
/usr/include/c++/6/bits/shared_ptr_base.h:1011:4: note: candidate expects at least 2 arguments, 1 provided
__shared_ptr(std::move(__r)).swap(*this);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/6/bits/shared_ptr_base.h:979:17: note: candidate: constexpr std::__shared_ptr<_Tp, _Lp>::__shared_ptr(std::nullptr_t) [with _Tp = long int; __gnu_cxx::_Lock_policy _Lp = (__gnu_cxx::_Lock_policy)2u; std::nullptr_t = std::nullptr_t]
constexpr __shared_ptr(nullptr_t) noexcept : __shared_ptr() { }
^~~~~~~~~~~~
/usr/include/c++/6/bits/shared_ptr_base.h:979:17: note: no known conversion for argument 1 from ‘std::remove_reference<std::__shared_ptr<long unsigned int, (__gnu_cxx::_Lock_policy)2u>&>::type {aka std::__shared_ptr<long unsigned int, (__gnu_cxx::_Lock_policy)2u>}’ to ‘std::nullptr_t’
/usr/include/c++/6/bits/shared_ptr_base.h:976:2: note: candidate: template<class _Tp1> std::__shared_ptr<_Tp, _Lp>::__shared_ptr(std::auto_ptr<_Up>&&)
__shared_ptr(std::auto_ptr<_Tp1>&& __r);
^~~~~~~~~~~~
/usr/include/c++/6/bits/shared_ptr_base.h:976:2: note: template argument deduction/substitution failed:
/usr/include/c++/6/bits/shared_ptr_base.h:1011:4: note: ‘std::remove_reference<std::__shared_ptr<long unsigned int, (__gnu_cxx::_Lock_policy)2u>&>::type {aka std::__shared_ptr<long unsigned int, (__gnu_cxx::_Lock_policy)2u>}’ is not derived from ‘std::auto_ptr<_Up>’
__shared_ptr(std::move(__r)).swap(*this);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/6/bits/shared_ptr_base.h:964:2: note: candidate: template<class _Tp1, class _Del, class> std::__shared_ptr<_Tp, _Lp>::__shared_ptr(std::unique_ptr<_Up, _Ep>&&)
__shared_ptr(std::unique_ptr<_Tp1, _Del>&& __r)
^~~~~~~~~~~~
/usr/include/c++/6/bits/shared_ptr_base.h:964:2: note: template argument deduction/substitution failed:
/usr/include/c++/6/bits/shared_ptr_base.h:1011:4: note: ‘std::remove_reference<std::__shared_ptr<long unsigned int, (__gnu_cxx::_Lock_policy)2u>&>::type {aka std::__shared_ptr<long unsigned int, (__gnu_cxx::_Lock_policy)2u>}’ is not derived from ‘std::unique_ptr<_Tp, _Dp>’
__shared_ptr(std::move(__r)).swap(*this);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/6/bits/shared_ptr_base.h:951:11: note: candidate: template<class _Tp1> std::__shared_ptr<_Tp, _Lp>::__shared_ptr(const std::__weak_ptr<_Tp1, _Lp>&)
explicit __shared_ptr(const __weak_ptr<_Tp1, _Lp>& __r)
^~~~~~~~~~~~
/usr/include/c++/6/bits/shared_ptr_base.h:951:11: note: template argument deduction/substitution failed:
/usr/include/c++/6/bits/shared_ptr_base.h:1011:4: note: ‘std::remove_reference<std::__shared_ptr<long unsigned int, (__gnu_cxx::_Lock_policy)2u>&>::type {aka std::__shared_ptr<long unsigned int, (__gnu_cxx::_Lock_policy)2u>}’ is not derived from ‘const std::__weak_ptr<_Tp>’
__shared_ptr(std::move(__r)).swap(*this);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/6/bits/shared_ptr_base.h:943:2: note: candidate: template<class _Tp1, class> std::__shared_ptr<_Tp, _Lp>::__shared_ptr(std::__shared_ptr<_Tp1, _Lp>&&)
__shared_ptr(__shared_ptr<_Tp1, _Lp>&& __r) noexcept
^~~~~~~~~~~~
/usr/include/c++/6/bits/shared_ptr_base.h:943:2: note: template argument deduction/substitution failed:
/usr/include/c++/6/bits/shared_ptr_base.h:935:7: note: candidate: std::__shared_ptr<_Tp, _Lp>::__shared_ptr(std::__shared_ptr<_Tp, _Lp>&&) [with _Tp = long int; __gnu_cxx::_Lock_policy _Lp = (__gnu_cxx::_Lock_policy)2u]
__shared_ptr(__shared_ptr&& __r) noexcept
^~~~~~~~~~~~
/usr/include/c++/6/bits/shared_ptr_base.h:935:7: note: no known conversion for argument 1 from ‘std::remove_reference<std::__shared_ptr<long unsigned int, (__gnu_cxx::_Lock_policy)2u>&>::type {aka std::__shared_ptr<long unsigned int, (__gnu_cxx::_Lock_policy)2u>}’ to ‘std::__shared_ptr<long int, (__gnu_cxx::_Lock_policy)2u>&&’
/usr/include/c++/6/bits/shared_ptr_base.h:931:2: note: candidate: template<class _Tp1, class> std::__shared_ptr<_Tp, _Lp>::__shared_ptr(const std::__shared_ptr<_Tp1, _Lp>&)
__shared_ptr(const __shared_ptr<_Tp1, _Lp>& __r) noexcept
^~~~~~~~~~~~
/usr/include/c++/6/bits/shared_ptr_base.h:931:2: note: template argument deduction/substitution failed:
/usr/include/c++/6/bits/shared_ptr_base.h:926:7: note: candidate: std::__shared_ptr<_Tp, _Lp>::__shared_ptr(const std::__shared_ptr<_Tp, _Lp>&) [with _Tp = long int; __gnu_cxx::_Lock_policy _Lp = (__gnu_cxx::_Lock_policy)2u]
__shared_ptr(const __shared_ptr&) noexcept = default;
^~~~~~~~~~~~
/usr/include/c++/6/bits/shared_ptr_base.h:926:7: note: no known conversion for argument 1 from ‘std::remove_reference<std::__shared_ptr<long unsigned int, (__gnu_cxx::_Lock_policy)2u>&>::type {aka std::__shared_ptr<long unsigned int, (__gnu_cxx::_Lock_policy)2u>}’ to ‘const std::__shared_ptr<long int, (__gnu_cxx::_Lock_policy)2u>&’
/usr/include/c++/6/bits/shared_ptr_base.h:922:2: note: candidate: template<class _Tp1> std::__shared_ptr<_Tp, _Lp>::__shared_ptr(const std::__shared_ptr<_Tp1, _Lp>&, _Tp*)
__shared_ptr(const __shared_ptr<_Tp1, _Lp>& __r, _Tp* __p) noexcept
^~~~~~~~~~~~
/usr/include/c++/6/bits/shared_ptr_base.h:922:2: note: template argument deduction/substitution failed:
/usr/include/c++/6/bits/shared_ptr_base.h:1011:4: note: candidate expects 2 arguments, 1 provided
__shared_ptr(std::move(__r)).swap(*this);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/6/bits/shared_ptr_base.h:917:9: note: candidate: template<class _Deleter, class _Alloc> std::__shared_ptr<_Tp, _Lp>::__shared_ptr(std::nullptr_t, _Deleter, _Alloc)
__shared_ptr(nullptr_t __p, _Deleter __d, _Alloc __a)
^~~~~~~~~~~~
/usr/include/c++/6/bits/shared_ptr_base.h:917:9: note: template argument deduction/substitution failed:
/usr/include/c++/6/bits/shared_ptr_base.h:1011:4: note: candidate expects 3 arguments, 1 provided
__shared_ptr(std::move(__r)).swap(*this);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/6/bits/shared_ptr_base.h:912:2: note: candidate: template<class _Deleter> std::__shared_ptr<_Tp, _Lp>::__shared_ptr(std::nullptr_t, _Deleter)
__shared_ptr(nullptr_t __p, _Deleter __d)
^~~~~~~~~~~~
/usr/include/c++/6/bits/shared_ptr_base.h:912:2: note: template argument deduction/substitution failed:
/usr/include/c++/6/bits/shared_ptr_base.h:1011:4: note: candidate expects 2 arguments, 1 provided
__shared_ptr(std::move(__r)).swap(*this);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/6/bits/shared_ptr_base.h:903:2: note: candidate: template<class _Tp1, class _Deleter, class _Alloc> std::__shared_ptr<_Tp, _Lp>::__shared_ptr(_Tp1*, _Deleter, _Alloc)
__shared_ptr(_Tp1* __p, _Deleter __d, _Alloc __a)
^~~~~~~~~~~~
/usr/include/c++/6/bits/shared_ptr_base.h:903:2: note: template argument deduction/substitution failed:
/usr/include/c++/6/bits/shared_ptr_base.h:1011:4: note: mismatched types ‘_Tp1*’ and ‘std::__shared_ptr<long unsigned int, (__gnu_cxx::_Lock_policy)2u>’
__shared_ptr(std::move(__r)).swap(*this);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/6/bits/shared_ptr_base.h:894:2: note: candidate: template<class _Tp1, class _Deleter> std::__shared_ptr<_Tp, _Lp>::__shared_ptr(_Tp1*, _Deleter)
__shared_ptr(_Tp1* __p, _Deleter __d)
^~~~~~~~~~~~
/usr/include/c++/6/bits/shared_ptr_base.h:894:2: note: template argument deduction/substitution failed:
/usr/include/c++/6/bits/shared_ptr_base.h:1011:4: note: mismatched types ‘_Tp1*’ and ‘std::__shared_ptr<long unsigned int, (__gnu_cxx::_Lock_policy)2u>’
__shared_ptr(std::move(__r)).swap(*this);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/6/bits/shared_ptr_base.h:884:11: note: candidate: template<class _Tp1> std::__shared_ptr<_Tp, _Lp>::__shared_ptr(_Tp1*)
explicit __shared_ptr(_Tp1* __p)
^~~~~~~~~~~~
/usr/include/c++/6/bits/shared_ptr_base.h:884:11: note: template argument deduction/substitution failed:
/usr/include/c++/6/bits/shared_ptr_base.h:1011:4: note: mismatched types ‘_Tp1*’ and ‘std::__shared_ptr<long unsigned int, (__gnu_cxx::_Lock_policy)2u>’
__shared_ptr(std::move(__r)).swap(*this);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/6/bits/shared_ptr_base.h:879:17: note: candidate: constexpr std::__shared_ptr<_Tp, _Lp>::__shared_ptr() [with _Tp = long int; __gnu_cxx::_Lock_policy _Lp = (__gnu_cxx::_Lock_policy)2u]
constexpr __shared_ptr() noexcept
^~~~~~~~~~~~
/usr/include/c++/6/bits/shared_ptr_base.h:879:17: note: candidate expects 0 arguments, 1 provided
CMakeFiles/hempeno.dir/build.make:141: recipe for target 'CMakeFiles/hempeno.dir/models/Brands.cc.o' failed
make[2]: *** [CMakeFiles/hempeno.dir/models/Brands.cc.o] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/hempeno.dir/all' failed
make[1]: *** [CMakeFiles/hempeno.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
Hi
We are not able to compile our project with c++17 because of some other library dependencies, (c++17 and related gcc is installed on the machine but in our cmake file we define our compiler as c++14)
However I install the drogon with following the installation wiki and add it to our project
But when I try to compile our application it gives the following error. Which seems to be related with c++17, how can we solve this problem, how can we build drogon with c++14
In file included from /usr/local/include/drogon/config.h:2:0,
from /usr/local/include/drogon/drogon.h:17,
from /tmp/tmp.KuZgKPJZbr/WebService/WSManager.cpp:7:
/usr/local/include/trantor/utils/config.h:6:12: error: ‘std::any’ has not been declared
using std::any;
^~~
/usr/local/include/trantor/utils/config.h:7:12: error: ‘std::any_cast’ has not been declared
using std::any_cast;
^~~~~~~~
In file included from /usr/local/include/drogon/config.h:2:0,
from /usr/local/include/drogon/drogon.h:17,
from /tmp/tmp.KuZgKPJZbr/WebService/WSManager.cpp:7:
/usr/local/include/trantor/utils/config.h:10:14: error: ‘string_view’ in namespace ‘std’ does not name a type
typedef std::string_view string_view;
Describe the bug
A clear and concise description of what the bug is.
To Reproduce
Steps to reproduce the behaviour:
cmake ..
...
...
File:../drogon/drogon_ctl/templates/plugin_h.csp
-- view classname:plugin_h
RegularExpression::compile(): Nested *?+.
RegularExpression::compile(): Error in compile.
CMake Error at CMakeLists.txt:179 (if):
if given arguments:"TMP_INS" "MATCHES" ";../drogon/trantor;"
Regular expression
";..//drogon/trantor;"
cannot compile-- Configuring incomplete, errors occurred!
See also ".../drogon/build/CMakeFiles/CMakeOutput.log".
Expected behavior
Generating done
Desktop (please complete the following information):
主要是为了对web服务器进行保密,或者对外部攻击者进行误导。
比如现在的头信息中,Server 是 drogon ,我想改成 IIS/6.5 - Powered-By: Asp/Vbscript,让人以为这个是是asp代码写的网站。
现在的情况下,如果使用 addHeader方法添加头信息,会生成2个头信息
Server: xxx
server: xxx
就是后来添加的,变成了小写
希望能,自定义一些头信息,如果addHeader 之后,覆盖原有的键,而不是新增键
There is always a compromise between saving a few cpu cycles (using sendfile, not using zip, etc..) and saving bandwidth (using on the fly gzip compression)
gzip_static is a nice compromise, saving both cpu cycles and bandwidth.
Would love to see this feature in drogon.
Thanks
Thanks for helping with previous enquiry. But now I have new problem.
I have just super basic class for testing:
class TestCtrl: public HttpController<TestCtrl, false>
{
std::string text;
public:
static void
initPathRouting()
{
registerMethod(&TestCtrl::main, "/", {Get});
}
TestCtrl(std::string const& a) : text {a}
{}
virtual void
main(HttpRequestPtr const& req,
std::function<void (const HttpResponsePtr &)> const& callback);
};
The problem is that I expected that going to 127.0.0.1:8848/
would call main
method. But instead I have to go to 127.0.0.1:8848/testctrl/
to do this?
I see that this is hardcoded in https://github.com/an-tao/drogon/blob/master/lib/inc/drogon/HttpController.h#L58
But is there other way than using registerMethod
of specifying absolute paths in HttpController
?
I started getting this issue just in last few days. I just tested your example ws_test.html
and it has same issue: it errors out in about 1 minute after establishing connection. I tested in both Chrome and Firefox and both browsers exhibit same behavior.
I slightly modified onclose
in ws_test.html
to show the code and evt
object.
ws.onclose = function(evt) {
log('DISCONNECT with code: ' + evt.code);
console.log(evt)
};
I'm pretty sure I did not have this problem right after websocket
controller was fixed. At the time I could have websocket connection open for long. So I think maybe there have been some new changes made in the last week that broke something?
p.s.
The issue can be circumvent using PING messages (as tested using websocat
). But from what I read browsers dont have API to send PING nor PONG messages.
Hi
Trying to test the websockets as shown in the example https://github.com/an-tao/drogon/blob/master/examples/simple_example/WebSocketTest.cc
But I dont now know to call it? Your example test dont cover the ws controller: https://github.com/an-tao/drogon/tree/master/examples/simple_example_test
I tried using https://github.com/vi/websocat but still nothing. Is there some example how to use the ws controller? maybe something similar to this (https://github.com/Corvusoft/restbed/blob/master/documentation/example/WEB_SOCKET.md#client) would be valuable.
when I put <%view %> code block at new line, as below:
The father csp
<%view child %>
the error comes out:
[ 14%] Generating father.h, father.cc
create view:/mnt/d/mytest/views/father.csp
create HttpView Class file by /mnt/d/mytest/views/father.csp
className=father
Scanning dependencies of target mytest
[ 28%] Building CXX object CMakeFiles/mytest.dir/father.cc.o
/mnt/d/mytest/build/father.cc:25:23: warning: missing terminating " character
\n";ther_tmp_stream << "
^
/mnt/d/mytest/build/father.cc:25:23: error: missing terminating " character
/mnt/d/mytest/build/father.cc:26:1: error: stray ‘\’ in program
father_tmp_stream << "This is father\n";
^
/mnt/d/mytest/build/father.cc:26:3: warning: missing terminating " character
father_tmp_stream << "This is father\n";
^
/mnt/d/mytest/build/father.cc:26:3: error: missing terminating " character
father_tmp_stream << "This is father\n";
^~
/mnt/d/mytest/build/father.cc: In member function ‘virtual std::string father::genText(const DrTemplateData&)’:
/mnt/d/mytest/build/father.cc:26:2: error: ‘n’ was not declared in this scope
father_tmp_stream << "This is father\n";
^
CMakeFiles/mytest.dir/build.make:115: recipe for target 'CMakeFiles/mytest.dir/father.cc.o' failed
make[2]: *** [CMakeFiles/mytest.dir/father.cc.o] Error 1
CMakeFiles/Makefile2:75: recipe for target 'CMakeFiles/mytest.dir/all' failed
make[1]: *** [CMakeFiles/mytest.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
but, if it end with the pre line, it works.
The father csp<%view child %>
How to keep a record of the connected clients, as it provides details with different data or send different messages to each one?
Hello, I'm using Debian 10 and g++ with std17 and can't compile very first example.
I've installed every library in installation tutorial.
Here is the compiler output.
sudo g++ -std=c++17 /home/us3r/Documents/wrk/Untitled-1.cpp
/usr/bin/ld: /tmp/ccMLPNve.o: in function `drogon::DrClassMap::demangle[abi:cxx11](char const*)':
Untitled-1.cpp:(.text._ZN6drogon10DrClassMap8demangleB5cxx11EPKc[_ZN6drogon10DrClassMap8demangleB5cxx11EPKc]+0x104): undefined reference to `trantor::Logger::Logger(trantor::Logger::SourceFile, int, trantor::Logger::LogLevel)'
/usr/bin/ld: Untitled-1.cpp:(.text._ZN6drogon10DrClassMap8demangleB5cxx11EPKc[_ZN6drogon10DrClassMap8demangleB5cxx11EPKc]+0x113): undefined reference to `trantor::Logger::stream()'
/usr/bin/ld: Untitled-1.cpp:(.text._ZN6drogon10DrClassMap8demangleB5cxx11EPKc[_ZN6drogon10DrClassMap8demangleB5cxx11EPKc]+0x131): undefined reference to `trantor::Logger::~Logger()'
/usr/bin/ld: Untitled-1.cpp:(.text._ZN6drogon10DrClassMap8demangleB5cxx11EPKc[_ZN6drogon10DrClassMap8demangleB5cxx11EPKc]+0x19a): undefined reference to `trantor::Logger::~Logger()'
/usr/bin/ld: /tmp/ccMLPNve.o: in function `drogon::IntranetIpFilter::IntranetIpFilter()':
Untitled-1.cpp:(.text._ZN6drogon16IntranetIpFilterC1Ev[_ZN6drogon16IntranetIpFilterC1Ev]+0x1f): undefined reference to `VTT for drogon::IntranetIpFilter'
/usr/bin/ld: Untitled-1.cpp:(.text._ZN6drogon16IntranetIpFilterC1Ev[_ZN6drogon16IntranetIpFilterC1Ev]+0x31): undefined reference to `vtable for drogon::IntranetIpFilter'
/usr/bin/ld: Untitled-1.cpp:(.text._ZN6drogon16IntranetIpFilterC1Ev[_ZN6drogon16IntranetIpFilterC1Ev]+0x3f): undefined reference to `vtable for drogon::IntranetIpFilter'
/usr/bin/ld: Untitled-1.cpp:(.text._ZN6drogon16IntranetIpFilterC1Ev[_ZN6drogon16IntranetIpFilterC1Ev]+0x4d): undefined reference to `vtable for drogon::IntranetIpFilter'
/usr/bin/ld: /tmp/ccMLPNve.o: in function `drogon::LocalHostFilter::LocalHostFilter()':
Untitled-1.cpp:(.text._ZN6drogon15LocalHostFilterC1Ev[_ZN6drogon15LocalHostFilterC1Ev]+0x1f): undefined reference to `VTT for drogon::LocalHostFilter'
/usr/bin/ld: Untitled-1.cpp:(.text._ZN6drogon15LocalHostFilterC1Ev[_ZN6drogon15LocalHostFilterC1Ev]+0x31): undefined reference to `vtable for drogon::LocalHostFilter'
/usr/bin/ld: Untitled-1.cpp:(.text._ZN6drogon15LocalHostFilterC1Ev[_ZN6drogon15LocalHostFilterC1Ev]+0x3f): undefined reference to `vtable for drogon::LocalHostFilter'
/usr/bin/ld: Untitled-1.cpp:(.text._ZN6drogon15LocalHostFilterC1Ev[_ZN6drogon15LocalHostFilterC1Ev]+0x4d): undefined reference to `vtable for drogon::LocalHostFilter'
/usr/bin/ld: /tmp/ccMLPNve.o: in function `drogon::NotFound::NotFound()':
Untitled-1.cpp:(.text._ZN6drogon8NotFoundC1Ev[_ZN6drogon8NotFoundC1Ev]+0x20): undefined reference to `VTT for drogon::NotFound'
/usr/bin/ld: Untitled-1.cpp:(.text._ZN6drogon8NotFoundC1Ev[_ZN6drogon8NotFoundC1Ev]+0x32): undefined reference to `vtable for drogon::NotFound'
/usr/bin/ld: Untitled-1.cpp:(.text._ZN6drogon8NotFoundC1Ev[_ZN6drogon8NotFoundC1Ev]+0x40): undefined reference to `vtable for drogon::NotFound'
/usr/bin/ld: Untitled-1.cpp:(.text._ZN6drogon8NotFoundC1Ev[_ZN6drogon8NotFoundC1Ev]+0x4e): undefined reference to `vtable for drogon::NotFound'
/usr/bin/ld: /tmp/ccMLPNve.o: in function `drogon::app()':
Untitled-1.cpp:(.text._ZN6drogon3appEv[_ZN6drogon3appEv]+0x5): undefined reference to `drogon::HttpAppFramework::instance()'
/usr/bin/ld: /tmp/ccMLPNve.o: in function `drogon::DrObject<drogon::NotFound>::DrAllocator::className[abi:cxx11]() const':
Untitled-1.cpp:(.text._ZNK6drogon8DrObjectINS_8NotFoundEE11DrAllocator9classNameB5cxx11Ev[_ZNK6drogon8DrObjectINS_8NotFoundEE11DrAllocator9classNameB5cxx11Ev]+0x3d): undefined reference to `typeinfo for drogon::NotFound'
/usr/bin/ld: /tmp/ccMLPNve.o: in function `drogon::DrObject<drogon::LocalHostFilter>::DrAllocator::className[abi:cxx11]() const':
Untitled-1.cpp:(.text._ZNK6drogon8DrObjectINS_15LocalHostFilterEE11DrAllocator9classNameB5cxx11Ev[_ZNK6drogon8DrObjectINS_15LocalHostFilterEE11DrAllocator9classNameB5cxx11Ev]+0x3d): undefined reference to `typeinfo for drogon::LocalHostFilter'
/usr/bin/ld: /tmp/ccMLPNve.o: in function `drogon::DrObject<drogon::IntranetIpFilter>::DrAllocator::className[abi:cxx11]() const':
Untitled-1.cpp:(.text._ZNK6drogon8DrObjectINS_16IntranetIpFilterEE11DrAllocator9classNameB5cxx11Ev[_ZNK6drogon8DrObjectINS_16IntranetIpFilterEE11DrAllocator9classNameB5cxx11Ev]+0x3d): undefined reference to `typeinfo for drogon::IntranetIpFilter'
/usr/bin/ld: /tmp/ccMLPNve.o: in function `std::enable_if<std::is_default_constructible<drogon::NotFound>::value, void>::type drogon::DrObject<drogon::NotFound>::DrAllocator::registerClass<drogon::NotFound>()':
Untitled-1.cpp:(.text._ZN6drogon8DrObjectINS_8NotFoundEE11DrAllocator13registerClassIS1_EENSt9enable_ifIXsrSt24is_default_constructibleIT_E5valueEvE4typeEv[_ZN6drogon8DrObjectINS_8NotFoundEE11DrAllocator13registerClassIS1_EENSt9enable_ifIXsrSt24is_default_constructibleIT_E5valueEvE4typeEv]+0x33): undefined reference to `drogon::DrClassMap::registerClass(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::function<drogon::DrObjectBase* ()> const&)'
/usr/bin/ld: /tmp/ccMLPNve.o: in function `std::enable_if<std::is_default_constructible<drogon::LocalHostFilter>::value, void>::type drogon::DrObject<drogon::LocalHostFilter>::DrAllocator::registerClass<drogon::LocalHostFilter>()':
Untitled-1.cpp:(.text._ZN6drogon8DrObjectINS_15LocalHostFilterEE11DrAllocator13registerClassIS1_EENSt9enable_ifIXsrSt24is_default_constructibleIT_E5valueEvE4typeEv[_ZN6drogon8DrObjectINS_15LocalHostFilterEE11DrAllocator13registerClassIS1_EENSt9enable_ifIXsrSt24is_default_constructibleIT_E5valueEvE4typeEv]+0x33): undefined reference to `drogon::DrClassMap::registerClass(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::function<drogon::DrObjectBase* ()> const&)'
/usr/bin/ld: /tmp/ccMLPNve.o: in function `std::enable_if<std::is_default_constructible<drogon::IntranetIpFilter>::value, void>::type drogon::DrObject<drogon::IntranetIpFilter>::DrAllocator::registerClass<drogon::IntranetIpFilter>()':
Untitled-1.cpp:(.text._ZN6drogon8DrObjectINS_16IntranetIpFilterEE11DrAllocator13registerClassIS1_EENSt9enable_ifIXsrSt24is_default_constructibleIT_E5valueEvE4typeEv[_ZN6drogon8DrObjectINS_16IntranetIpFilterEE11DrAllocator13registerClassIS1_EENSt9enable_ifIXsrSt24is_default_constructibleIT_E5valueEvE4typeEv]+0x33): undefined reference to `drogon::DrClassMap::registerClass(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::function<drogon::DrObjectBase* ()> const&)'
collect2: error: ld returned 1 exit status
```
Not an issue, just reporting test results. Should be closed.
$ ./test.sh
20190610 15:00:45.864121 UTC 26139 DEBUG [TestController] TestController constructor - TestController.h:22
_
__| |_ __ ___ __ _ ___ _ __
/ _` | '__/ _ \ / _` |/ _ \| '_ \
| (_| | | | (_) | (_| | (_) | | | |
\__,_|_| \___/ \__, |\___/|_| |_|
|___/
empty custom config!
20190610 15:00:45.875527 UTC 26139 DEBUG [operator()] Event loop is running! - main.cc:191
/slow (GET) HttpSimpleController: example::TestController
/path/name (GET) HttpSimpleController: controllerClassName
/path/name (POST) HttpSimpleController: controllerClassName
/tpost (POST) HttpSimpleController: example::TestController
/tpost (OPTIONS) HttpSimpleController: example::TestController
/json (GET) HttpSimpleController: JsonTestController
/view (GET) HttpSimpleController: TestViewCtl
/view (POST) HttpSimpleController: TestViewCtl
/view (Head) HttpSimpleController: TestViewCtl
/view (PUT) HttpSimpleController: TestViewCtl
/view (DELETE) HttpSimpleController: TestViewCtl
/view (OPTIONS) HttpSimpleController: TestViewCtl
/forward (GET) HttpSimpleController: ForwardCtrl
/listpara (GET) HttpSimpleController: ListParaCtl
/test (GET) HttpSimpleController: example::TestController
/test (POST) HttpSimpleController: example::TestController
/test (Head) HttpSimpleController: example::TestController
/test (PUT) HttpSimpleController: example::TestController
/test (DELETE) HttpSimpleController: example::TestController
/test (OPTIONS) HttpSimpleController: example::TestController
/pipe (GET) HttpSimpleController: PipeliningTest
/ (GET) HttpSimpleController: example::TestController
/ (POST) HttpSimpleController: TestViewCtl
/api/Attachment (GET) HttpController: Attachment::get
/api/Attachment/upload (POST) HttpController: Attachment::upload
/api/Attachment/download (GET) HttpController: Attachment::download
/api/v1/ApiTest (GET) HttpController: ApiTest::rootGet
/api/v1/ApiTest (POST) HttpController: ApiTest::rootPost
/api/v1/ApiTest (OPTIONS) HttpController: ApiTest::rootPost
/api/v1/ApiTest/get/{2}/{1} (GET) HttpController: ApiTest::get
/api/v1/ApiTest/{1}/List?P2={2} (GET) HttpController: ApiTest::your_method_name
/api/v1/ApiTest/static (GET) HttpController: ApiTest::staticApi
/api/v1/ApiTest/static (POST) HttpController: ApiTest::staticApi
/api/v1/ApiTest/static (PUT) HttpController: ApiTest::staticApi
/api/v1/ApiTest/static (DELETE) HttpController: ApiTest::staticApi
/api/v1/ApiTest/static (OPTIONS) HttpController: ApiTest::staticApi
/api/v1/ApiTest/get/{1} (GET) HttpController: ApiTest::get2
/absolute/{1} (GET) HttpController: ApiTest::get2
/api/v1/ApiTest/json (POST) HttpController: ApiTest::jsonTest
/api/v1/ApiTest/form (POST) HttpController: ApiTest::formTest
/api/v1/Test/get/{2}/{1} (GET) HttpController: Test::get
/api/v1/Test/{2}/info (GET) HttpController: Test::list
/api/v1/handle1/{1}/{2}/?p3={3}&p4={4} (GET) Handler: void (A::*)(std::shared_ptr<drogon::HttpRequest> const&, std::function<void (std::shared_ptr<drogon::HttpResponse> const&)>&&, int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int) const
/api/v1/handle1/{1}/{2}/?p3={3}&p4={4} (POST) Handler: void (A::*)(std::shared_ptr<drogon::HttpRequest> const&, std::function<void (std::shared_ptr<drogon::HttpResponse> const&)>&&, int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int) const
/api/v1/handle1/{1}/{2}/?p3={3}&p4={4} (Head) Handler: void (A::*)(std::shared_ptr<drogon::HttpRequest> const&, std::function<void (std::shared_ptr<drogon::HttpResponse> const&)>&&, int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int) const
/api/v1/handle1/{1}/{2}/?p3={3}&p4={4} (PUT) Handler: void (A::*)(std::shared_ptr<drogon::HttpRequest> const&, std::function<void (std::shared_ptr<drogon::HttpResponse> const&)>&&, int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int) const
/api/v1/handle1/{1}/{2}/?p3={3}&p4={4} (DELETE) Handler: void (A::*)(std::shared_ptr<drogon::HttpRequest> const&, std::function<void (std::shared_ptr<drogon::HttpResponse> const&)>&&, int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int) const
/api/v1/handle1/{1}/{2}/?p3={3}&p4={4} (OPTIONS) Handler: void (A::*)(std::shared_ptr<drogon::HttpRequest> const&, std::function<void (std::shared_ptr<drogon::HttpResponse> const&)>&&, int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int) const
/api/v1/handle11/{1}/{2}/?p3={3}&p4={4} (GET) Handler: void (*)(std::shared_ptr<drogon::HttpRequest> const&, std::function<void (std::shared_ptr<drogon::HttpResponse> const&)>&&, int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)
/api/v1/handle11/{1}/{2}/?p3={3}&p4={4} (POST) Handler: void (*)(std::shared_ptr<drogon::HttpRequest> const&, std::function<void (std::shared_ptr<drogon::HttpResponse> const&)>&&, int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)
/api/v1/handle11/{1}/{2}/?p3={3}&p4={4} (Head) Handler: void (*)(std::shared_ptr<drogon::HttpRequest> const&, std::function<void (std::shared_ptr<drogon::HttpResponse> const&)>&&, int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)
/api/v1/handle11/{1}/{2}/?p3={3}&p4={4} (PUT) Handler: void (*)(std::shared_ptr<drogon::HttpRequest> const&, std::function<void (std::shared_ptr<drogon::HttpResponse> const&)>&&, int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)
/api/v1/handle11/{1}/{2}/?p3={3}&p4={4} (DELETE) Handler: void (*)(std::shared_ptr<drogon::HttpRequest> const&, std::function<void (std::shared_ptr<drogon::HttpResponse> const&)>&&, int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)
/api/v1/handle11/{1}/{2}/?p3={3}&p4={4} (OPTIONS) Handler: void (*)(std::shared_ptr<drogon::HttpRequest> const&, std::function<void (std::shared_ptr<drogon::HttpResponse> const&)>&&, int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)
/api/v1/handle2/{1}/{2} (GET) Handler: main::{lambda(std::shared_ptr<drogon::HttpRequest> const&, std::function<void (std::shared_ptr<drogon::HttpResponse> const&)>&&, int, float)#1}
/api/v1/handle2/{1}/{2} (POST) Handler: main::{lambda(std::shared_ptr<drogon::HttpRequest> const&, std::function<void (std::shared_ptr<drogon::HttpResponse> const&)>&&, int, float)#1}
/api/v1/handle2/{1}/{2} (Head) Handler: main::{lambda(std::shared_ptr<drogon::HttpRequest> const&, std::function<void (std::shared_ptr<drogon::HttpResponse> const&)>&&, int, float)#1}
/api/v1/handle2/{1}/{2} (PUT) Handler: main::{lambda(std::shared_ptr<drogon::HttpRequest> const&, std::function<void (std::shared_ptr<drogon::HttpResponse> const&)>&&, int, float)#1}
/api/v1/handle2/{1}/{2} (DELETE) Handler: main::{lambda(std::shared_ptr<drogon::HttpRequest> const&, std::function<void (std::shared_ptr<drogon::HttpResponse> const&)>&&, int, float)#1}
/api/v1/handle2/{1}/{2} (OPTIONS) Handler: main::{lambda(std::shared_ptr<drogon::HttpRequest> const&, std::function<void (std::shared_ptr<drogon::HttpResponse> const&)>&&, int, float)#1}
/api/v1/handle3/{1}/{2} (GET) Handler: B
/api/v1/handle3/{1}/{2} (POST) Handler: B
/api/v1/handle3/{1}/{2} (Head) Handler: B
/api/v1/handle3/{1}/{2} (PUT) Handler: B
/api/v1/handle3/{1}/{2} (DELETE) Handler: B
/api/v1/handle3/{1}/{2} (OPTIONS) Handler: B
/api/v1/handle4/{4}/{3}/{1} (GET) Handler: std::function<void (std::shared_ptr<drogon::HttpRequest> const&, std::function<void (std::shared_ptr<drogon::HttpResponse> const&)>&&, int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)>
/api/v1/handle4/{4}/{3}/{1} (POST) Handler: std::function<void (std::shared_ptr<drogon::HttpRequest> const&, std::function<void (std::shared_ptr<drogon::HttpResponse> const&)>&&, int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)>
/api/v1/handle4/{4}/{3}/{1} (Head) Handler: std::function<void (std::shared_ptr<drogon::HttpRequest> const&, std::function<void (std::shared_ptr<drogon::HttpResponse> const&)>&&, int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)>
/api/v1/handle4/{4}/{3}/{1} (PUT) Handler: std::function<void (std::shared_ptr<drogon::HttpRequest> const&, std::function<void (std::shared_ptr<drogon::HttpResponse> const&)>&&, int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)>
/api/v1/handle4/{4}/{3}/{1} (DELETE) Handler: std::function<void (std::shared_ptr<drogon::HttpRequest> const&, std::function<void (std::shared_ptr<drogon::HttpResponse> const&)>&&, int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)>
/api/v1/handle4/{4}/{3}/{1} (OPTIONS) Handler: std::function<void (std::shared_ptr<drogon::HttpRequest> const&, std::function<void (std::shared_ptr<drogon::HttpResponse> const&)>&&, int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)>
/CustomCtrl/{1} (GET) HttpController: CustomCtrl::hello
/chat (GET) WebsocketController: example::WebSocketTest
20190610 15:00:45.877341 UTC 26139 INFO Start to run... - HttpAppFrameworkImpl.cc:242
Initializing daemon mode
Test http requests and responses.
1 Good GET /slow
2 Good GET /api/v1/apitest/get/111
3 Good POST /api/v1/apitest/json
4 Good GET /
5 Good GET /tpost
6 Good POST /tpost
7 Good OPTIONS /tpost
8 Good OPTIONS /api/v1/apitest
9 Good OPTIONS /slow
10 Good OPTIONS /*
11 Good OPTIONS /api/v1/apitest/static
12 Good POST /api/v1/apitest
13 Good GET /api/v1/apitest
14 Good GET /api/v1/apitest/get/abc/123
15 Good GET /api/v1/apitest/3.14/List
16 Good GET /api/v1/apitest/static
17 Good POST /api/v1/apitest/static
18 Good GET /api/v1/apitest/get/111
19 Good GET /api/v1/handle11/11/2 2/?p3=3 x
20 Good GET /api/v1/handle2/111/222
21 Good GET /api/v1/handle4/444/333/111
22 Good GET /index.html
23 Good GET /index.html
24 Good GET /drogon.jpg
25 Good GET /../../drogon.jpg
26 Good GET /customctrl/antao
27 Good GET /absolute/123
28 Good POST /api/v1/apitest/form
29 Good GET /api/attachment/download
30 Good POST /api/attachment/upload
31 Good GET /slow
32 Good GET /drogon.jpg
33 Good GET /slow (https)
34 Good GET /api/v1/apitest/get/111 (https)
35 Good POST /api/v1/apitest/json (https)
36 Good GET / (https)
37 Good GET /tpost (https)
38 Good POST /tpost (https)
39 Good OPTIONS /tpost (https)
40 Good OPTIONS /api/v1/apitest (https)
41 Good OPTIONS /slow (https)
42 Good OPTIONS /* (https)
43 Good OPTIONS /api/v1/apitest/static (https)
44 Good POST /api/v1/apitest (https)
45 Good GET /api/v1/apitest (https)
46 Good GET /api/v1/apitest/get/abc/123 (https)
47 Good GET /api/v1/apitest/3.14/List (https)
48 Good GET /api/v1/apitest/static (https)
49 Good POST /api/v1/apitest/static (https)
50 Good GET /api/v1/apitest/get/111 (https)
51 Good GET /api/v1/handle11/11/2 2/?p3=3 x (https)
52 Good GET /api/v1/handle2/111/222 (https)
53 Good GET /api/v1/handle4/444/333/111 (https)
54 Good GET /index.html (https)
55 Good GET /index.html (https)
56 Good GET /drogon.jpg (https)
57 Good GET /../../drogon.jpg (https)
58 Good GET /customctrl/antao (https)
59 Good GET /absolute/123 (https)
60 Good POST /api/v1/apitest/form (https)
61 Good GET /api/attachment/download (https)
62 Good POST /api/attachment/upload (https)
63 Good GET /slow (https)
64 Good GET /drogon.jpg (https)
Test the WebSocket
20190610 15:00:50.168176 UTC 26149 INFO Start to run... - HttpAppFrameworkImpl.cc:242
ws connected!
new message:haha!!!
new message:
recv a pong
Test the pipelining
20190610 15:00:52.195653 UTC 26151 INFO Start to run... - HttpAppFrameworkImpl.cc:242
20190610 15:00:53.205546 UTC 26151 DEBUG [operator()] Good! - HttpPipeliningTest.cc:36
Test the drogon_ctl
create a project named drogon_test
create a http simple controller:Test::SimpleCtrl
create a http controller:Test::HttpCtrl
create a websocket controller:Test::WebsockCtrl
create a http filter:Test::TestFilter
create a plugin:Test::TestPlugin
-- The C compiler identification is GNU 7.3.0
-- The CXX compiler identification is GNU 7.3.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- This is gcc version:: 7.3.0
-- c++17
-- Found jsoncpp: /usr/local/include
-- Found UUID: /usr/lib/aarch64-linux-gnu/libuuid.so
-- Found OpenSSL: /home/linuxbrew/.linuxbrew/Cellar/openssl/1.0.2r/lib/libcrypto.so (found version "1.0.2r")
-- Found ZLIB: /usr/lib/aarch64-linux-gnu/libz.so (found version "1.2.11")
-- Could NOT find PostgreSQL (missing: PostgreSQL_LIBRARY PostgreSQL_INCLUDE_DIR PostgreSQL_TYPE_INCLUDE_DIR)
-- Could NOT find SQLITE3 (missing: SQLITE3_LIBRARY SQLITE3_INCLUDE_DIR)
-- Configuring done
-- Generating done
-- Build files have been written to: /home/vinay/dev/drogon/build/examples/drogon_test/build
Scanning dependencies of target drogon_test
[ 14%] Building CXX object CMakeFiles/drogon_test.dir/main.cc.o
[ 28%] Building CXX object CMakeFiles/drogon_test.dir/controllers/Test_HttpCtrl.cc.o
[ 42%] Building CXX object CMakeFiles/drogon_test.dir/controllers/Test_SimpleCtrl.cc.o
[ 57%] Building CXX object CMakeFiles/drogon_test.dir/controllers/Test_WebsockCtrl.cc.o
[ 71%] Building CXX object CMakeFiles/drogon_test.dir/filters/Test_TestFilter.cc.o
[ 85%] Building CXX object CMakeFiles/drogon_test.dir/plugins/Test_TestPlugin.cc.o
[100%] Linking CXX executable drogon_test
[100%] Built target drogon_test
Everything is ok!
Hi
I tried to compile it using C++14, and there are multiple errors. In your code you use, for instance, std::string_view
, std::any
which are C++17 features only.
I don't see how one could use drogon in C++14 only project?
If this is the case, they your description C++14/C++17
is confusing and it would be better to change it to C++17.
由于没有了config.h,导致lib/src/SharedLibManager.cc出现编译错误。COMPILER_COMMAND等宏都没有定义。
Would you be able to support Windows in a future release if you switched to libuv? It's used by Node.
现在的情况下,如果跨域,浏览器,会自生成 options 请求,
现在框架还不支持 options 请求...
希望能增加 options 请求处理
Describe the bug
Wiki 中是否表述有误?
地址:https://github.com/an-tao/drogon/wiki/DbClient-cn
章节: 10.3.2.2、std::future execSqlAsync
代码:
std::cout << i++ << ": user name is " << row["user_name"].as<std::string> << std::endl;
是否应为:
as<std::string>()
I see that there is some support for websockets in Drogon. Just wonder if Server-sent events are also supported (or planned) as an alternative to websockets, when only server->client comunication is desired.
当访问网站时,应该象所有的web服务器那样,默认返回index.html,
Describe the bug
I was following the wiki to create a csp file. Although I am getting a segmentation fault when I make a request to the endpoint.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Expected html as seen in wiki with a table of parameters
Segmentation Fault when request happens:
Desktop (please complete the following information):
Controller Source files:
demo_v1_user.h:
#pragma once
#include <drogon/HttpController.h>
using namespace drogon;
namespace demo
{
namespace v1
{
class User:public drogon::HttpController<User>
{
public:
METHOD_LIST_BEGIN
//use METHOD_ADD to add your custom processing function here;
//METHOD_ADD(User::get,"/get/{2}/{1}",Get);//path is /demo/v1/User/get/{arg2}/{arg1}
//METHOD_ADD(User::your_method_name,"/{1}/{2}/list",Get);//path is /demo/v1/User/{arg1}/{arg2}/list
//ADD_METHOD_TO(User::your_method_name,"/absolute/path/{1}/{2}/list",Get);//path is /demo/v1//absolute/path/{arg1}/{arg2}/list
METHOD_ADD(User::getParameters,"list_para",Get);
METHOD_LIST_END
//your declaration of processing function maybe like this:
//void get(const HttpRequestPtr& req,std::function<void (const HttpResponsePtr &)> &&callback,int p1,std::string p2);
//void your_method_name(const HttpRequestPtr& req,std::function<void (const HttpResponsePtr &)> &&callback,double p1,int p2) const;
void getParameters(const HttpRequestPtr &req,
std::function<void (const HttpResponsePtr &)> &&callback);
};
}
}
demo_v1_user.cc:
#include "demo_v1_User.h"
using namespace demo::v1;
//add definition of your processing function here
void User::getParameters(const HttpRequestPtr &req,
std::function<void (const HttpResponsePtr &)> &&callback)
{
auto para = req->getParameters();
HttpViewData data;
data.insert("title","ListParameters");
data.insert("parameters",para);
auto resp=HttpResponse::newHttpViewResponse("ListParameters.csp",data);
callback(resp);
};
Csp file:
<!DOCTYPE html>
<html>
<%c++
auto para=@@.get<std::map<std::string,std::string>>("parameters");
%>
<head>
<meta charset="UTF-8">
<title>[[ title ]]</title>
</head>
<body>
<%c++ if(para.size()>0){%>
<H1>Parameters</H1>
<table border="1">
<tr>
<th>name</th>
<th>value</th>
</tr>
<%c++ for(auto iter:para){%>
<tr>
<td>{%iter.first%}</td>
<td><%c++ $$<<iter.second;%></td>
</tr>
<%c++}%>
</table>
<%c++ }else{%>
<H1>no parameter</H1>
<%c++}%>
</body>
</html>
drogon::app().loadConfigFile("config.json"); //加载配置
sleep(5); //不起作用
//加载数据到内存当中
try {
Cache::loadAdminRoles(); //加载一些数据到内存当中
} catch (std::exception& err) {
std::cout << err.what() << std::endl;
return 1;
}
drogon::app().run(); //框架运行
我想在 loadConfigFile() 和 run() 之间,加载一些数据库信息到内存当中, 如何实现
现在的情况:
虽然web是数据库不敏感的, 但,我想能有多快就提多快。
so, 有没有办法,让我同时可以使用 dbclient 和 fastdbclient ?
In other words, can I share the same WebSocketConnectionPtr
with various threads which are going to call send()
possibly at the same time?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.