GithubHelp home page GithubHelp logo

cutelyst / cutelyst Goto Github PK

View Code? Open in Web Editor NEW
887.0 887.0 113.0 6.17 MB

A C++ Web Framework built on top of Qt, using the simple approach of Catalyst (Perl) framework.

Home Page: https://cutelyst.org

License: BSD 3-Clause "New" or "Revised" License

CMake 2.97% C++ 93.36% C 0.03% Shell 0.07% Roff 0.97% CSS 2.60%
catalyst cplusplus cpp cross-platform fastcgi http-server json qt uwsgi webframework

cutelyst's Introduction

Cutelyst - The Qt Web Framework Cutelyst logo

A Web Framework built on top of Qt, using the simple and elegant approach of Catalyst (Perl) framework.

Qt's meta object system is what powers the core of Cutelyst, it allows for introspecting controller's methods signatures and generate matching actions that can be invoked later.

BENCHMARKS

Don't trust us on being fast, check out the most comprehensive web framework benchmarks by TechEmpower http://www.techempower.com/benchmarks/

FEATURES:

  • Cross-platform
  • Stable API/ABI - v3 tagged from v3.x.x, v2 tags, v1 on v1.x.x branch (unmaintained)
  • Pluggable Engines
    • Cutelyst::Server - A cross-platform and fast server engine
      • HTTP/1.1 - Pipelining and Keep-Alive
      • HTTP/2 - Upgrade to H2, ALPN negotiation on HTTPS and direct H2C
      • FastCGI - Pipelining and Keep-Alive
  • WebSockets
  • REST with ActionREST
  • Plugin based views
    • Cutelee (A Qt implementation of Django's template engine)
    • JSON
    • Email
  • Dispatcher
    • Chained
    • Path
  • Plugins
    • Session
    • Authentication (with PBKDF2)
    • Authorization with RoleACL
    • StatusMessage
    • Validator (to validate user input)
    • CSRF protection
    • Memcached
    • UserAgent
  • Asynchronous processing (just don't use local QEventLoops or it will eventually crash)
    • Async SQL with ASql
  • Upload parser
  • JSON body as QJsonDocument when uploaded data is in JSON format
  • C++20
  • Chunked reponses (via QIODevice write API)
  • Request profiling/stats
  • Unit tested
  • QtCreator integration

DOCUMENTATION

Get started with our Tutorial or check the API.

COMMUNITY

The Cutelyst project IRC channel is #cutelyst on freenode.

Or you can use the Mailing List

REQUIREMENTS

  • CMake - for the build system (>= 3.16)
  • Qt - the core library of this framework (>= 6.2)

LICENSE

The source code is available is under the 3-Clause BSD.

cutelyst's People

Contributors

adriaandegroot avatar andreagen0r avatar blizzardofozz avatar brano543 avatar buschmann23 avatar dantti avatar fd00 avatar fdar0536 avatar ffontaine avatar lyarbean avatar maidis avatar mardy avatar mikepooh avatar plaristote avatar pre-commit-ci[bot] avatar raineforest avatar sanekt197 avatar sibbi77 avatar simonaw avatar sw-ps avatar texpert avatar thewolfwillcome avatar xcorail avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cutelyst's Issues

Setting up Cutelyst on fedora

Hi. I install uwsgi and qtbase and clearsilver(not package names just hints) and I compile and install cutelyst successfully. I create the Hello project but when I run cmake .. in the build directory It gives me these:

CMake Error at CMakeLists.txt:16 (find_package):
By not providing "FindCutelystQt5.cmake" in CMAKE_MODULE_PATH this project
has asked CMake to find a package configuration file provided by
"CutelystQt5", but CMake did not find one.

Could not find a package configuration file provided by "CutelystQt5" with
any of the following names:

CutelystQt5Config.cmake
cutelystqt5-config.cmake

Add the installation prefix of "CutelystQt5" to CMAKE_PREFIX_PATH or set
"CutelystQt5_DIR" to a directory containing one of the above files. If
"CutelystQt5" provides a separate development package or SDK, be sure it
has been installed.

-- Configuring incomplete, errors occurred!

I googled it a bit and set CMAKE_PREFIX_PATH and CutelystQt5_DIR but non helps. the problem still remains

[wsgi] Unable to bind to specified IPv6 address

It is not possible to bind to a specified IPv6 address using wsgi:-

$ cutelyst-wsgi2 --application build/src/libcmlyst.so --http-socket '[2001:470:1f1d:bd1:9e8e:99ff:fedc:26b3]:12001' --ini build/src/cmlyst.conf --chdir /tmp/CMlyst/ --static-map /static=root/static
Installing EPoll event loop
Loading INI configuration: build/src/cmlyst.conf section: wsgi
Cutelyst-WSGI starting
*** WARNING: you are running Cutelyst-WSGI without its master process manager ***
Failed to listen on TCP: [2001:470:1f1d:bd1:9e8e:99ff:fedc:26b3]:12001 : The address is protected

MongoDb

Anything to connect MongoDB?

Apache mod_proxy_fcgi and cutelyst

Is it somehow possible to use cutelyst-wsgi and it's FastCGI socket together with Apache's mod_proxy_fcgi? I tried any weird combination of settings for a proxy including SetHandler in many combinations as well as ProxyPass, but nothing wants to work. cutelyst-wsgi every time only seems to get the root "/" url, not the other parts of the URI, like in the following endless redirect:

925:925 cutelyst.core[info] cutelyst-wsgi powered by Cutelyst 1.6.0, Qt 5.7.1.
925:925 wsgi[debug] Starting threads
925:925 cutelyst.request[debug] "GET" request for "/" from "127.0.0.1"
925:925 cutelyst.dispatcher[debug] Path is "/"
925:925 cutelyst.response[debug] Redirecting to "http://localhost/login" 302
925:925 cutelyst.stats[debug] Response Code: 302; Content-Type: text/html; charset=utf-8; Content-Length: 297
925:925 cutelyst.stats[info] Request took: 0.001000s (1000.000/s)
.--------+-----------.
| Action | Time      |
.--------+-----------.
| /Auto  | 0.001000s |
| /End   | 0.000000s |
.--------+-----------.
925:925 cutelyst.request[debug] "GET" request for "/" from "127.0.0.1"
925:925 cutelyst.dispatcher[debug] Path is "/"
925:925 cutelyst.response[debug] Redirecting to "http://localhost/login" 302
925:925 cutelyst.stats[debug] Response Code: 302; Content-Type: text/html; charset=utf-8; Content-Length: 297
925:925 cutelyst.stats[info] Request took: 0.001000s (1000.000/s)

And so on until Firefox stops it.

Using the script from this Apache bug report I tried to determine which stuff is send to the socket when calling the example url http://localhost/path/to/my/3/controllers?foo=bar

This is the output without setting proxy-fcgi-pathinfo.

$VAR1 = {
          'DOCUMENT_ROOT' => '/srv/www/htdocs',
          'HTTP_HOST' => 'localhost',
          'SCRIPT_NAME' => '/path',
          'SCRIPT_FILENAME' => '/srv/www/htdocs/path',
          'SERVER_SIGNATURE' => '',
          'SERVER_ADMIN' => '[no address given]',
          'FCGI_ROLE' => 'RESPONDER',
          'PATH_TRANSLATED' => '/srv/www/htdocs/to/my/3/controllers',
          'HTTP_USER_AGENT' => 'Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Firefox/52.0',
          'HTTP_ACCEPT_LANGUAGE' => 'de-DE,de;q=0.8,en-GB;q=0.6,en-US;q=0.4,en;q=0.2',
          'PATH_INFO' => '/to/my/3/controllers',
          'QUERY_STRING' => 'foo=bar',
          'HTTP_ACCEPT_ENCODING' => 'gzip, deflate',
          'HTTP_CONNECTION' => 'keep-alive',
          'REQUEST_METHOD' => 'GET',
          'HTTP_UPGRADE_INSECURE_REQUESTS' => '1',
          'REQUEST_URI' => '/path/to/my/3/controllers?foo=bar',
          'GATEWAY_INTERFACE' => 'CGI/1.1',
          'CONTEXT_DOCUMENT_ROOT' => '/srv/www/htdocs',
          'SERVER_SOFTWARE' => 'Apache',
          'SERVER_ADDR' => '127.0.0.1',
          'PATH' => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
          'SERVER_PROTOCOL' => 'HTTP/1.1',
          'SERVER_PORT' => '80',
          'HTTP_DNT' => '1',
          'REMOTE_PORT' => '58456',
          'REQUEST_SCHEME' => 'http',
          'REMOTE_ADDR' => '127.0.0.1',
          'HTTP_ACCEPT' => 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
          'CONTEXT_PREFIX' => '',
          'SERVER_NAME' => 'localhost'
        };

And this is the output with enabling proxy-fcgi-pathinfo:

$VAR1 = {
          'SERVER_NAME' => 'localhost',
          'HTTP_ACCEPT' => 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
          'CONTEXT_PREFIX' => '',
          'REMOTE_ADDR' => '127.0.0.1',
          'REMOTE_PORT' => '58464',
          'REQUEST_SCHEME' => 'http',
          'HTTP_DNT' => '1',
          'SERVER_PORT' => '80',
          'PATH' => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
          'SERVER_PROTOCOL' => 'HTTP/1.1',
          'SERVER_ADDR' => '127.0.0.1',
          'proxy-fcgi-pathinfo' => '1',
          'CONTEXT_DOCUMENT_ROOT' => '/srv/www/htdocs',
          'SERVER_SOFTWARE' => 'Apache',
          'GATEWAY_INTERFACE' => 'CGI/1.1',
          'REQUEST_URI' => '/path/to/my/3/controllers?foo=bar',
          'REQUEST_METHOD' => 'GET',
          'HTTP_UPGRADE_INSECURE_REQUESTS' => '1',
          'PATH_INFO' => '/to/my/3/controllers',
          'HTTP_ACCEPT_ENCODING' => 'gzip, deflate',
          'QUERY_STRING' => 'foo=bar',
          'HTTP_CONNECTION' => 'keep-alive',
          'FCGI_ROLE' => 'RESPONDER',
          'HTTP_USER_AGENT' => 'Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Firefox/52.0',
          'PATH_TRANSLATED' => '/srv/www/htdocs/to/my/3/controllers',
          'HTTP_ACCEPT_LANGUAGE' => 'de-DE,de;q=0.8,en-GB;q=0.6,en-US;q=0.4,en;q=0.2',
          'SERVER_ADMIN' => '[no address given]',
          'SERVER_SIGNATURE' => '',
          'SCRIPT_FILENAME' => '/srv/www/htdocs/path',
          'SCRIPT_NAME' => '/path',
          'HTTP_HOST' => 'localhost',
          'DOCUMENT_ROOT' => '/srv/www/htdocs'
        };

I am not sure where to search for this issue. I am using mod_proxy_fcgi together with PHP-FPM without any problems. But might also be, that I am using a completely wrong configuration for Cutelyst. :)

Session data not saved to file

Since updating to Cutelyst 1.7.0, the session data is not saved to file anymore using the SessionStoreFile. The session file is created as it should be in /tmp/<Appname>/session/data/36a0d035a21c40d881..., but it is empty. So, performing a login using Authentication::authenticate() is not possible.

I will check if this is the same behavior using the memcached session store.

Hello Daniel!

Look please, the project does not build under Windows for the generator - NMake Makefiles.

Cmake command:
cmake ..\cutelyst -G"NMake Makefiles"
-- The C compiler identification is MSVC 19.11.25547.0
-- The CXX compiler identification is MSVC 19.11.25547.0
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/VC/Tools/MSVC/14.11.25503/bin/Hostx64/x64/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/VC/Tools/MSVC/14.11.25503/bin/Hostx64/x64/cl.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/VC/Tools/MSVC/14.11.25503/bin/Hostx64/x64/cl.exe
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/VC/Tools/MSVC/14.11.25503/bin/Hostx64/x64/cl.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- PLUGIN: View::Grantlee, disabled.
-- PLUGIN: View::ClearSilver, disabled.
-- PLUGIN: View::Email, disabled.
-- PLUGIN: Memcached, disabled.
-- PLUGIN: MemcachedSessionStore, disable
-- PLUGIN: StaticCompressed, disabled
-- PLUGIN: CSRFProtection, disbaled
-- Found Doxygen: C:/Program Files/doxygen/bin/doxygen.exe (found version "1.8.13") found components: doxygen dot
-- Doxygen and dot found. make docs target is available
-- Configuring done
-- Generating done
-- Build files have been written to: E:/Cutelyst/cutelyst/build_NMake_Makefiles

Cmake command:
cmake --build . --config Release
...
[ 87%] Building CXX object tests/CMakeFiles/testactionroleacl_exec.dir/testactionroleacl_exec_autogen/mocs_compilation.cpp.obj
mocs_compilation.cpp
[ 88%] Linking CXX executable ..\testactionroleacl_exec.exe
LINK Pass 1: command "C:\PROGRA2\MICROS1\2017\ENTERP1\VC\Tools\MSVC\14111.255\bin\Hostx64\x64\link.exe /nologo @CMakeFiles\testactionroleacl_exec.dir\objects1.rsp /out:..\testactionroleacl_exec.exe /implib:testactionroleacl_exec.lib /pdb:E:\Cutelyst\cutelyst\build_NMake_Makefiles\testactionroleacl_exec.pdb /version:0.0 /machine:x64 /debug /INCREMENTAL /subsystem:console ..\Cutelyst\Plugins\Authentication\cutelyst_qt5_plugin_authentication.lib ..\Cutelyst\Plugins\Session\cutelyst_qt5_plugin_session.lib coverage_test.lib ..\Cutelyst\cutelyst-qt5.lib C:\Qt\5.10.0\msvc2017_64\lib\Qt5Networkd.lib C:\Qt\5.10.0\msvc2017_64\lib\Qt5Testd.lib C:\Qt\5.10.0\msvc2017_64\lib\Qt5Cored.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /MANIFEST /MANIFESTFILE:CMakeFiles\testactionroleacl_exec.dir/intermediate.manifest CMakeFiles\testactionroleacl_exec.dir/manifest.res" failed (exit code 1169) with the following output:
coverage_test.lib(coverageobject.cpp.obj) : error LNK2005: "public: __cdecl QMap<class QString,class QVariant>::QMap<class QString,class QVariant>(void)" (??0?$QMap@VQString@@VQVariant@@@@qeaa@XZ) єцх юяЁхфхыхэ т cutelyst_qt5_plugin_authentication.lib(cutelyst_qt5_plugin_authentication.dll)
coverage_test.lib(coverageobject.cpp.obj) : error LNK2005: "public: __cdecl QMap<class QString,class QVariant>::~QMap<class QString,class QVariant>(void)" (??1?$QMap@VQString@@VQVariant@@@@qeaa@XZ) єцх юяЁхфхыхэ т cutelyst_qt5_plugin_authentication.lib(cutelyst_qt5_plugin_authentication.dll)
coverage_test.lib(coverageobject.cpp.obj) : error LNK2005: "public: class QMap<class QString,class QVariant>::iterator __cdecl QMap<class QString,class QVariant>::insert(class QString const &,class QVariant const &)" (?insert@?$QMap@VQString@@VQVariant@@@@qeaa?AViterator@1@AEBVQString@@AEBVQVariant@@@z) єцх юяЁхфхыхэ т cutelyst_qt5_plugin_authentication.lib(cutelyst_qt5_plugin_authentication.dll)
..\testactionroleacl_exec.exe : fatal error LNK1169: юсэрЁєцхэ ьэюуюъЁрЄэю юяЁхфхыхээ√щ ёшьтюы - юфшэ шыш сюыхх
NMAKE : fatal error U1077: "C:\Program Files\CMake\bin\cmake.exe" : возвращенный код "0xffffffff"
Stop.
NMAKE : fatal error U1077: "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.11.25503\bin\HostX64\x64\nmake.exe" : возвращенный код "0x2"
Stop.
NMAKE : fatal error U1077: "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.11.25503\bin\HostX64\x64\nmake.exe" : возвращенный код "0x2"
Stop.

Success in your hard and extremely important work!
Aleksey
[email protected]

Large response handling

Hi,
I am experiencing some issues with sending large responses. It also behaves a bit inconsistently (sometimes ok sometimes not).
My request handler looks like this

c->response()->body() = QByteArray("abcd").repeated(1024*1024);

and it is not able to send the data and I don't know why

curl $URL
curl: (52) Empty reply from server

and I also tried wget

wget $URL
--2017-04-09 10:48:12--  URL
Resolving localhost... ::1, 127.0.0.1
Connecting to localhost|::1|:3000... connected.
HTTP request sent, awaiting response... 200 OK
Length: 0 [text/html]
Saving to: ‘$FILE’

$FILE                                                  [ <=>                                                                                                                                     ]       0  --.-KB/s    in 0s      

2017-04-09 10:48:12 (0.00 B/s) - ‘$FILE’ saved [0/0]

and that's just a 4MiB response. I tried it with 4KiB response and it is fine. I was also able to send responses 10s of MBs in size but not consistently. Maybe it's something I'm doing wrong with QByteArray. Is there any extra restriction on body size of responses? For large responses it would maybe be easier to implement some stream interface. Do you experience the same issues/Can you replicate the behaviour?

Thanks!

epoll_ctl() failed (No such file or directory)

I tried to activate the epoll event dispatcher and got the following critical error. So, now I am not sure if it is a compilation error of mine or if I am enabling it the wrong way.

cutelyst-wsgi command line:

CUTELYST_EVENT_LOOP_EPOLL=true QT_LOGGING_RULES=*.debug=true cutelyst-wsgi --ini /path/to/myapp.ini -a /path/to/myapp.so --uid myuser --gid mygroupdi --h1 127.0.0.1:3000

Error:

868:4868 cutelyst.core[info] Skaffari powered by Cutelyst 1.6.0, Qt 5.7.1.
spawned WSGI worker 1 (pid: 4870, cores: 6)
4870:4870 [critical] void EventDispatcherEPollPrivate::unregisterSocketNotifier(QSocketNotifier*): epoll_ctl() failed (No such file or directory)
4870:4870 wsgi[debug] Starting threads

After killing it (Ctrl + C):

CSIGINT/SIGQUIT received, killing workers...
4868:4868 default[critical] void EventDispatcherEPollPrivate::wake_up_handler(): internal error, testAndSetRelease(1, 0) failed!
Memory access error

Environment:
Linux 4.10.13
glibc 2.25
Qt 5.7.1
Cutelyst 1.6.0

My Thought About Grantlee

Should we just drop Grantlee from building process?

  1. The link is broken and I couldn't find any new repo related to it.
  2. Its only tested against Qt4 (although it can be build against Qt5) and its hard to support legacy app.
  3. It makes the cmake result looks ugly...

Document that `multipart/form-data` is available as `uploads`

Requests with multipart/form-data in their bodies can be uploaded files (uploads), but they can also be simple key value pairs (akin to application/x-www-form-urlencoded parameters). This happens for example when using the Fetch API:

var formData = new FormData();
formData.append('value1', 'key1');
formData.append('value2', 'key2');
fetch('foo/bar', {
    method: 'POST',
    data: formData
});

You would need to get these key value pairs with c->request()->uploadMap() or c->request()->uploads(). I think that the formulation is a bit awkward considering that multipart/form-data does not have to contain binary files. But I can get over that. 😉

However, I believe it should at least be documented that uploads and friends actually contain multipart/form-data. I had to scratch my head for some time before I realized why these parameters weren't available from c->request()->bodyParameters().

Cutelyst and cutelyst-wsgi license

Hello!

Would you kindly explain how is the Cutelyst is licensed?

The README.md mentions, that the library is licensed under LGPLv2+. And it is fine for me because I can create closed-source applications without license violation as long as Cutelyst is dynamically linked. However, header comments in source and header files say, that the library is licensed under GPLv2.

So the question is: what is the real license of Cutelyst?

And as a consequence of this question: what is the license of cutelyst-wsgi? The sources mention GPLv2. And that is the moment I become confused: technically, the application I develop is a shared library, loaded by cutelyst-wsgi. Does it matter, that the application must be licensed under GPLv2 as well to use it with the cutelyst-wsgi server?

Thanks in advance!

Best regards,
Innokentiy

routing with numbers

I built a new controller, name is "v5". And i saw on the console output,

.--------------------------+----------------------.
| Path                     | Private              |
.--------------------------+----------------------.
| /...                     | /defaultPage         |
| /                        | /index               |
| /v/5                     | /v/5/index 

I need only "/v5" but cutelyst convert it to "/v/5". How can i solve it?

Hard-coded QT_LOGGING_CONF environment variable in cutelyst-wsgi

Hello!

I have accidentally discovered, that main() function of cutelyst-wsgi has the following line 41:

qputenv("QT_LOGGING_CONF", "/home/daniel/cutelyst.ini");

I am not sure if it affects anything in the program, but I think that it should not be hard-coded.

Best regards,
Innokentiy

Users Need Single RoleACL Example

I am very interested in using RoleACL, but the documentation in the headers is pretty sparse.

Could you create one code example on the Wiki demonstrating it's use?

Request: Let Qt app take over (an open) websocket for low level interaction.

There are some javascript libs and apps which are using websockets to interact with common services to provie e.g. voice talk (mumble), remote access (vnc, ssh). It would be great if one could use Qt to divert or syphon throgh the traffic to corresponding servers or to implementation in Qt app itself.

E.g. if we have a vnc server implementation in Qt and would like to serve a (java script) vnc webclient to users, it would be great to be able to reuse port opened by cutelyst or already provided websocket.

Specify controllername when Action conflicts

If it's easy to do, it might be worthwhile to specify the name of the controller of the action that it is in conflict. Maybe even better if it only does so if it's a different action than the action that was not registered:

Current error:

17163:17163 cutelyst.dispatcher[critical] Not registering Action "index" of controller "Root2" because it conflicts with  "index"

Proposed error:

17163:17163 cutelyst.dispatcher[critical] Not registering Action "index" of controller "Root2" because it conflicts with  "index" of controller "Root"

I'll look into this myself if you think it's an improvement.

Grantlee Templates no longer loaded

Sorry, it's me again.
But unfortunately with cutelyst 1.6.0 (i.e. latest commit) Grantlee templates are no longer loaded. With the same setup and cutelyst 1.4.0 everything is fine.
The debug log shows that Cutelyst::GrantleeView->execute is executed but unfortunately Content-Length is returned as 0.

20513:20513 cutelyst.request[debug] "GET" request for "/" from "127.0.0.1"
20513:20513 cutelyst.dispatcher[debug] Path is "/"
20513:20513 cutelyst.grantlee[debug] Rendering template "index.html"
20513:20513 cutelyst.stats[debug] Response Code: 200; Content-Type: text/html; charset=utf-8; Content-Length: 0
20513:20513 cutelyst.stats[info] Request took: 0.000002s (500000.000/s)
.---------------------------------+-----------.
| Action                          | Time      |
.---------------------------------+-----------.
| /index                          | 0.000000s |
| /End                            | 0.000000s |
| Cutelyst::GrantleeView->execute | 0.000000s |
.---------------------------------+-----------.

Database ORM, Json Serializer.

I really like your project, actually I'm using Wt before and it is very good except its lacks file processing tools that I can easily get from Qt QImage, QFile, QXmlStreamReader and etc.

But, Wt also come with pretty good stuff too. The database ORM (Wt:Dbo) which make my job really easy and Dbo::Json that can easily convert Wt::Dbo object to Json. Which is crucial to make Json RESTful service.

Do have any plan to implement such this features in Cutelyst?

Add sensible default arguments to CredentialPassword::createPassword?

Hasing passwords properly is hard and the user should be left as little room for error as possible. My suggestion is to add default arguments to the CredentialPassword::createPassword function so that users don't have to study this subject themselves (or don't do that, and make their application insecure).

Multiple sources recommend testing the maximum amount of iterations whose performance is still acceptable. But 10000 is probably a sensible default. So something like (magic numbers should probably become static variables):

static QByteArray createPassword(const QByteArray &password,
    QCryptographicHash::Algorithm method = QCryptographicHash::Sha512,
    int iterations = 10000, int saltByteSize = 16, int hashByteSize = 16);

Adding similar arguments to CredentialPassword::pbkdf2 is probably a good idea. The tutorial would also need to be updated.

Let me know what you think.

uriFor in Grantlee Template

Hi! This is not really an issue but more like a question of best practice.
In Catalyst or Flask/Jinja2 I can access the uri_for method directly for creating links for an action. Unfortunately in Grantlee there is no direct way of calling a function with a string parameter. E.g. {{c.uriFor("authen/logout")}} does not work. The Parser is choking on the parameter "Could not parse the remainder, (\"authen/logout\") from c.uriFor(\"authen/logout\")

Right now, as a workaround, I created a two-level map so that I can access the routes via dot-lookup:

QVariantHash controllers;
for( Controller *controller: c->app()->controllers() ) {
  QVariantHash routes;
  for( Action *action: controller->actions() ) {
    routes[action->name()] = c->uriFor(action);
  }
  controllers[controller->objectName()] = routes;
}
c->setStash("controllers", controllers);

Having this routes map on my stash I can do something like this in the template:

<p> <a href="{{controllers.Authen.logout}}">Logout</a> </p>

Sure, better have it in the init method to not have the map generated on every request.

Or is there another (easier) way to do this? -- Besides creating a Grantlee Filter that appearently accepts string parameters.

Class name "Cutelyst::RenderView*" is not registerd

When trying to run cmlyst or my own projects through uWSGI it does not start up, because of the following error:

 cutelyst.controller[crit]  Class name "Cutelyst::RenderView*" is not registerd, you can register it with qRegisterMetaType< Cutelyst::RenderView* >();

SIGINT doesn't kill Cutelyst if run with -r option anymore

When I run the cutelyst2 executable with the -r option, it keeps running after a SIGINT signal (ctrl+C in terminal). Specifically the process that is bound to the terminal is terminated, but the server keeps running.

Please let me know if it's reproducible. I'm running Cutelyst 2.1.0.

rpmlint warnings

Building cutelyst on openSUSE's build service produces two rpmlint warnings I am not sure of if the are relevant. :)

  1. shared-lib-calls-exit /usr/lib64/libcutelyst-qt5.so.1.6.0 exit@GLIBC_2.2.5
This library package calls exit() or _exit(), probably in a non-fork()
context. Doing so from a library is strongly discouraged - when a library
function calls exit(), it prevents the calling program from handling the
error, reporting it to the user, closing files properly, and cleaning up any
state that the program has. It is preferred for the library to return an
actual error code and let the calling program decide how to handle the
situation.
  1. missing-call-to-setgroups-before-setuid /usr/lib64/libcutelyst_wsgi_qt5.so.1.6.0
This executable is calling setuid and setgid without setgroups or initgroups.
There is a high probability this means it didn't relinquish all groups, and
this would be a potential security issue to be fixed. Seek POS36-C on the web
for details about the problem.

FastCGI socket and multiple threads

Using a local FastCGI socket together with multiple threads like in the following cutelyst-wsgi call

cutelyst-wsgi -M -t auto --fastcgi-socket /run/myapp.sock --chown-socket myuser:www --socket-access ug --uid myuser --gid mygroup --pidfile /run/myapp.pid  -a /path/to/libmyapp.so

Fails either directly or after a while for some of the threads with the following error message:

21504:21508 default[warning] QSocketNotifier: Invalid socket 6 and type 'Read', disabling...
21504:21506 default[warning] QSocketNotifier: Invalid socket 6 and type 'Read', disabling...
21504:21510 default[warning] QSocketNotifier: Invalid socket 6 and type 'Read', disabling...

In the example above six threads have been started. Three of them failed directly after first socket access with the above messages. Socket is accessed by Apache via ProxyPass.

Using multiple processes, each with on thread, will not fail with the above error.

Failed to Compile Against Qt5.5

I'm using Ubuntu 15.04 Desktop 64-bit and Qt 5.5 (downloaded from www.qt.io) and fail to compile latest Cutelyst (commit 3700256).

Here is the errors :

/opt/Qt5/5.5/gcc_64/include/QtCore/qdatetime.h:343:28: note: no known conversion for argument 2 from ‘QMap<QString, QString>’ to ‘QDate&’
/opt/Qt5/5.5/gcc_64/include/QtCore/qdatetime.h:345:28: note: QDataStream& operator>>(QDataStream&, QTime&)
Q_CORE_EXPORT QDataStream &operator>>(QDataStream &, QTime &);
^
/opt/Qt5/5.5/gcc_64/include/QtCore/qdatetime.h:345:28: note: no known conversion for argument 2 from ‘QMap<QString, QString>’ to ‘QTime&’
/opt/Qt5/5.5/gcc_64/include/QtCore/qdatetime.h:347:28: note: QDataStream& operator>>(QDataStream&, QDateTime&)
Q_CORE_EXPORT QDataStream &operator>>(QDataStream &, QDateTime &);
^
/opt/Qt5/5.5/gcc_64/include/QtCore/qdatetime.h:347:28: note: no known conversion for argument 2 from ‘QMap<QString, QString>’ to ‘QDateTime&’
Cutelyst/CMakeFiles/cutelyst-qt5.dir/build.make:537: recipe for target 'Cutelyst/CMakeFiles/cutelyst-qt5.dir/application.cpp.o' failed
make[2]: *** [Cutelyst/CMakeFiles/cutelyst-qt5.dir/application.cpp.o] Error 1
CMakeFiles/Makefile2:81: recipe for target 'Cutelyst/CMakeFiles/cutelyst-qt5.dir/all' failed

Add Q_COMPILER_INITIALIZER_LISTS to doxygen PREDEFINED vairable

Currently some constructors that are using initializer lists are missing from the generated documentation because they are only available to compilers that support this C++11 feature. Adding Q_COMPILER_INITIALIZER_LISTS to the Doxygen variable PREDEFINED will show them in the docs.

Development server timing

I am having weird timing issue with the development server. For some reason it is off by a factor of exactly 1000... For example request calculating something that takes 8.5s realtime shows up as only 0.008494s in the server output.

918:918 cutelyst.dispatcher[debug] Path is "fibonacci"
918:918 cutelyst.dispatcher[debug] Arguments are "1000000"
918:918 cutelyst.stats[debug] Response Code: 200; Content-Type: application/json; Content-Length: 208999
918:918 cutelyst.stats[info] Request took: 0.008500s (117.647/s)
.------------------+-----------.
| Action           | Time      |
.------------------+-----------.
| /fibonacci/index | 0.008494s |
| /End             | 0.000000s |
.------------------+-----------.

screenshot_20170404_215046
I am using cutelyst 1.6.0 that was compiled from master during the last couple days. It would be nice to have precise timing on the development server.
Thank you.

cutelyst --server -r does not restart on file change

Since Version 1.5.0 the development server does no longer restart on file change when started with cutelyst --server -r.
I am running Qt 5.8.0, grantlee 5.1.0, libsimplemail-qt-git 1.3.0

Can anyone reproduce this?

Setting Up The Cutelyst QtCreator Assistant

I am sorry but I didn't know any other place to ask this but how can one setup cutelyst's qtcreator assistant? I searched the wiki and didn't find anything there but:

If you are using QtCreator it's easier to setup the Cutelyst QtCreator assistant, and create the project there. The command line tool will be used in this tutorial as not everyone like QtCreator (I love it!).

I googled it but nothing came up. I'm sorry if this is not an issue but you don't have any tutorial for it

Configuration of a mere generated Hello app is failing on Windows

There is a cutelystqt5-config.cmake and it is located in the \cutelyst\build folder, but the configuration is failing:

C:\cutelyst\build\Debug>cd build

C:\cutelyst\build\Debug\Hello\build>cmake ..
-- Building for: Visual Studio 15 2017
-- The C compiler identification is MSVC 19.10.25019.0
-- The CXX compiler identification is MSVC 19.10.25019.0
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.10.25017/bin/HostX86/x86/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.10.25017/bin/HostX86/x86/cl.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.10.25017/bin/HostX86/x86/cl.exe
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.10.25017/bin/HostX86/x86/cl.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Error at CMakeLists.txt:9 (find_package):
  By not providing "FindCutelystQt5.cmake" in CMAKE_MODULE_PATH this project
  has asked CMake to find a package configuration file provided by
  "CutelystQt5", but CMake did not find one.

  Could not find a package configuration file provided by "CutelystQt5" with
  any of the following names:

    CutelystQt5Config.cmake
    cutelystqt5-config.cmake

  Add the installation prefix of "CutelystQt5" to CMAKE_PREFIX_PATH or set
  "CutelystQt5_DIR" to a directory containing one of the above files.  If
  "CutelystQt5" provides a separate development package or SDK, be sure it
  has been installed.

-- Configuring incom
rate development package or SDK, be sure it
  has been installed.

-- Configuring incomplete, errors occurred!
See also "C:/cutelyst/build/Debug/Hello/build/CMakeFiles/CMakeOutput.log".

Unable to load Grantlee template from examples

Using Tutorial_02 I get errors when trying to load Grantlee template:

*** Operational MODE: single process ***
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 22351)
spawned uWSGI worker 1 (pid: 22352, cores: 1)
cutelyst.uwsgi[debug] Cutelyst loading application: /home/alko/Development/Qt/Capoeira/CutelystSandBox/Hello/build/src/libHello.so
cutelyst.uwsgi[debug] Loaded application: "Hello"
/usr/bin/uwsgi: symbol lookup error: /home/alko/Development/Qt/Capoeira/CutelystSandBox/Hello/build/src/libHello.so: undefined symbol: _ZN8Cutelyst12GrantleeViewC1EP7QObjectRK7QString
DAMN ! worker 1 (pid: 22352) died :( trying respawn ...
Respawned uWSGI worker 1 (new pid: 22353)
cutelyst.uwsgi[debug] Cutelyst loading application: /home/alko/Development/Qt/Capoeira/CutelystSandBox/Hello/build/src/libHello.so
cutelyst.uwsgi[debug] Loaded application: "Hello"
/usr/bin/uwsgi: symbol lookup error: /home/alko/Development/Qt/Capoeira/CutelystSandBox/Hello/build/src/libHello.so: undefined symbol: _ZN8Cutelyst12GrantleeViewC1EP7QObjectRK7QString

Tutorial_03 still has the old ViewEngine, which was removed in 0.10.0

Question: grantlee i18n support

What is the way to use the the i18n support of Grantlee? Support for the i18n tags is compiled in, "grantlee_i18ntags.so" plugin is available, but simply using i18n "some string" is not working with the following warning:

"Invalid block tag on line 0: 'i18n''. Did you forget to register or load this tag?"

Ho do I have to register or load it? I can not find any documentation about it. (Not meening that it is not there. ;) )

Do I have to load the QLocalizer of Grantlee to use the i18n tags even without any translation files?

cutelyst-wsgi on Windows doesn't work

I was trying to use cutelyst-wsgi on Windows, but the threads were not started.

It seems that the problem is caused due to a missing Q_EMIT forked(0); in the WindowsFork::exec() function.

Question: cutelyst app in subdirectory

Is it somehow possible to run a Cutelyst application in a subdirectory like http://www.example.com/myapp/?

Or where would be the entry point to implement this in the application?

Example on Authentication in Chapter 5 not working

https://github.com/cutelyst/cutelyst/wiki/Tutorial_05_Authentication

On windows 10 MSVC 2017 with everything running on localhost (so last note about clock skew should not be an issue), and every time I get authentication failure.

Ran same test on a Docker image (Alpine 3.6) and same issue.

259:259 cutelyst.request[debug] Body Parameters are:
.-----------+--------.
| Parameter | Value  |
.-----------+--------.
| password  | mypass |
| submit    | Submit |
| username  | test01 |
.-----------+--------.
259:259 cutelyst.dispatcher[debug] Path is "login"
259:259 default[debug] FOUND USER ->  1
259:259 cutelyst.plugin.credentialpassword[debug] Password didn't match
259:259 cutelyst.grantlee[debug] Rendering template "login.html"

Web controls

I am wondering if a done knows of material design web components that can be code generated from QML ?

The reason I ask this is because at the moment we all use QML to build normal Qt apps, but if we could use the same QML if there was a library to code gen JavaScript from QML for example.

Document applicability to coexisting w/ GUI desktop application

Cutelyst is recommended in various spots on the Web where people are asking, ~"How can I write one Qt application that can be used on both Desktop/Mobile and via web browser?"

I assume that this would require using completely separate view code for Desktop (e.g. QML) versus web (e.g. Grantlee), and so the only code re-use would be any application logic.

This issue is both a request to clarify that my assumption is correct, and also that you proactively document this for future people evaluating Cutelyst with a similar goal in mind.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.