Skip to content

Setting CROW_DISABLE_STATIC_DIR disables the blueprint paths all together #941

@morphonedev

Description

@morphonedev

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @gittiver@morphonedev

      Issue actions

        Setting CROW_DISABLE_STATIC_DIR disables the blueprint paths all together · Issue #941 · CrowCpp/Crow