drogonframework / drogon

Drogon: A C++14/17/20 based HTTP web application framework running on Linux/macOS/Unix/Windows
MIT License
11.06k stars 1.06k forks source link

View example does not compile #1963

Open DerDominikNatter opened 4 months ago

DerDominikNatter commented 4 months ago

Describe the bug I can't get the view example to compile

To Reproduce Steps to reproduce the behavior: Copy paste the example into a project and see the error

Expected behavior Successful compilation of the example

Screenshots image

Desktop (please complete the following information):

Additional context I can use views without a problem, but the example code does not work

albaropereyra22 commented 4 months ago

You are probably copying something incorrectly or is not copy able. Try something else like cloning this repo https://github.com/albaropereyra22/login_session

Let me know if this works for you.

On Thu, Feb 22, 2024, 2:48 PM Dominik Natter @.***> wrote:

Describe the bug I can't get the view example to compile

To Reproduce Steps to reproduce the behavior: Copy paste the example into a project and see the error

Expected behavior Successful compilation of the example

Screenshots image.png (view on web) https://github.com/drogonframework/drogon/assets/49405083/b9975ec5-ee63-4e0b-8439-801352476050

Desktop (please complete the following information):

  • OS: Arch Linux
  • Browser Chrome
  • Version 19.3

Additional context I can use views without a problem, but the example code does not work

— Reply to this email directly, view it on GitHub https://github.com/drogonframework/drogon/issues/1963, or unsubscribe https://github.com/notifications/unsubscribe-auth/BBZFRVYWIR6EDJT27QTBY23YU7DK5AVCNFSM6AAAAABDVY7EZ6VHI2DSMVQWIX3LMV43ASLTON2WKOZSGE2TAMBXGI4DAMQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>

Todesbengel0 commented 3 months ago

Hi, I am having the same problem that @DerDominikNatter described.

The repo given by @albaropereyra22 does not contain the example from the official drogon documentation (https://drogonframework.github.io/drogon-docs/#/ENG-06-View?id=drogon's-csp). Especially, the csp files from the repo do not contain any C++ code, which is the main focus of the referred documentation page.

The problem with the example from the documentation seems to be that utils is not included in the generated ListParameters.cc.

albaropereyra22 commented 3 months ago

The parameters need to be escaped using utils.

Check out this example: https://github.com/albaropereyra22/your_project_name

On Wed, Mar 13, 2024, 6:58 AM Dan Eisenkrämer @.***> wrote:

Hi, I am having the same problem that @DerDominikNatter https://github.com/DerDominikNatter described.

The repo given by @albaropereyra22 https://github.com/albaropereyra22 does not contain the example from the official drogon documentation ( https://drogonframework.github.io/drogon-docs/#/ENG-06-View?id=drogon's-csp ). Especially, the csp files from the repo do not contain any C++ code, which is the main focus of the referred documentation page.

The problem with the example from the documentation seems to be that utils is not included in the generated ListParameters.cc.

— Reply to this email directly, view it on GitHub https://github.com/drogonframework/drogon/issues/1963#issuecomment-1994472114, or unsubscribe https://github.com/notifications/unsubscribe-auth/BBZFRVYMMDMSCBABA6TIH3LYYBLRZAVCNFSM6AAAAABDVY7EZ6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSOJUGQ3TEMJRGQ . You are receiving this because you were mentioned.Message ID: @.***>

Todesbengel0 commented 3 months ago

Yes, that works! The include from drogon/utils/Utilities.h was missing in the csp file. Would it be possible to add the lines in the official example from https://drogonframework.github.io/drogon-docs/#/ENG-06-View?id=drogon's-csp, so that the example works when others want to work with it? 😁

The parameters need to be escaped using utils. Check out this example: https://github.com/albaropereyra22/your_project_name On Wed, Mar 13, 2024, 6:58 AM Dan Eisenkrämer @.> wrote: Hi, I am having the same problem that @DerDominikNatter https://github.com/DerDominikNatter described. The repo given by @albaropereyra22 https://github.com/albaropereyra22 does not contain the example from the official drogon documentation ( https://drogonframework.github.io/drogon-docs/#/ENG-06-View?id=drogon's-csp ). Especially, the csp files from the repo do not contain any C++ code, which is the main focus of the referred documentation page. The problem with the example from the documentation seems to be that utils is not included in the generated ListParameters.cc. — Reply to this email directly, view it on GitHub <#1963 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/BBZFRVYMMDMSCBABA6TIH3LYYBLRZAVCNFSM6AAAAABDVY7EZ6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSOJUGQ3TEMJRGQ . You are receiving this because you were mentioned.Message ID: @.>

dr-blade commented 2 months ago

As @Todesbengel0 described, please modify the example from https://github.com/drogonframework/drogon/wiki/ENG-06-View by adding `<%inc

include <drogon/utils/Utilities.h>

%>` on top of the csp example file. Thanks