Skip to content
Merged
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
4 changes: 4 additions & 0 deletions src/webserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,10 @@ void webserver::request_completed(void *cls, struct MHD_Connection *connection,
}

bool webserver::register_resource(const std::string& resource, http_resource* hrm, bool family) {
if (hrm == nullptr) {
throw std::invalid_argument("The http_resource pointer cannot be null");
}

if (single_resource && ((resource != "" && resource != "/") || !family)) {
throw std::invalid_argument("The resource should be '' or '/' and be marked as family when using a single_resource server");
}
Expand Down
5 changes: 5 additions & 0 deletions test/integ/ws_start_stop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,11 @@ LT_BEGIN_AUTO_TEST(ws_start_stop_suite, single_resource_not_default_resource)
ws.stop();
LT_END_AUTO_TEST(single_resource_not_default_resource)

LT_BEGIN_AUTO_TEST(ws_start_stop_suite, register_resource_nullptr_throws)
httpserver::webserver ws = httpserver::create_webserver(PORT);
LT_CHECK_THROW(ws.register_resource("/test", nullptr));
LT_END_AUTO_TEST(register_resource_nullptr_throws)

LT_BEGIN_AUTO_TEST(ws_start_stop_suite, thread_per_connection_fails_with_max_threads)
{ // NOLINT (internal scope opening - not method start)
httpserver::webserver ws = httpserver::create_webserver(PORT)
Expand Down
Loading