Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting CROW_DISABLE_STATIC_DIR disables the blueprint paths all together #941

Open
morphonedev opened this issue Nov 11, 2024 · 0 comments · May be fixed by #944
Open

Setting CROW_DISABLE_STATIC_DIR disables the blueprint paths all together #941

morphonedev opened this issue Nov 11, 2024 · 0 comments · May be fixed by #944
Labels
bug Something isn't working

Comments

@morphonedev
Copy link

morphonedev commented Nov 11, 2024

Description
Setting the CROW_DISABLE_STATIC_DIR define, e.g. via
target_compile_definitions(Crow INTERFACE CROW_DISABLE_STATIC_DIR) in the CMakeLists.txt, disables all blueprint paths.

Steps to reproduce the behavior:

  1. Set the define CROW_DISABLE_STATIC_DIR
  2. Compile the example_blueprint.cpp
  3. Run it and try to access any blueprint route

To make the error more apparent

changing the line:
app.loglevel(crow::LogLevel::Debug).port(18080).run();
to

    auto future = app.loglevel(crow::LogLevel::Debug).port(18080).run_async();
    app.debug_print();
    future.get();

clearly shows no routes at all.

(2024-11-11 22:54:53) [DEBUG   ] Routing:
(2024-11-11 22:54:53) [INFO    ] Crow/master server is running at http://0.0.0.0:18080 using 2 threads
(2024-11-11 22:54:53) [INFO    ] Call `app.loglevel(crow::LogLevel::Warning)` to hide Info level logs.
(2024-11-11 22:54:53) [DEBUG   ] 0000026706D1B590 {0} queue length: 1

Expected behavior
The non static blueprint routes should still be available.

Analysis

It looks like the code

#ifndef CROW_DISABLE_STATIC_DIR
            add_blueprint();
            add_static_dir();
#endif

in app.h is the only position where add_blueprint() and within it router_.validate_bp(); gets called.

One possible fix would be to move router_.validate_bp(); into the Crow::validate method.

@gittiver gittiver added the bug Something isn't working label Nov 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants