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

refactor: make validate_bp independent from CROW_DISABLE_STATIC_DIR #942

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
workflow_dispatch:

env:
BUILD_TYPE: Release
Expand Down
11 changes: 5 additions & 6 deletions include/crow/app.h
Original file line number Diff line number Diff line change
Expand Up @@ -460,8 +460,8 @@ namespace crow
}
#endif

/// \brief Apply blueprints
void add_blueprint()
/// \brief Apply blueprints static routes
void add_blueprint_static_dirs()
{
#if defined(__APPLE__) || defined(__MACH__)
if (router_.blueprints().empty()) return;
Expand All @@ -480,9 +480,7 @@ namespace crow
res.set_static_file_info_unsafe(static_dir_ + file_path_partial);
res.end();
});
}

router_.validate_bp();
}
}

/// \brief Go through the rules, upgrade them if possible, and add them to the list of rules
Expand All @@ -503,13 +501,14 @@ namespace crow
void validate()
{
router_.validate();
router_.validate_bp();
}

/// \brief Run the server
void run()
{
#ifndef CROW_DISABLE_STATIC_DIR
add_blueprint();
add_blueprint_static_dirs();
add_static_dir();
#endif
validate();
Expand Down
2 changes: 1 addition & 1 deletion tests/unittest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3643,7 +3643,7 @@ TEST_CASE("blueprint")
bp.register_blueprint(sub_bp);
sub_bp.register_blueprint(sub_sub_bp);

app.add_blueprint();
app.add_blueprint_static_dirs();
app.add_static_dir();
app.validate();

Expand Down