Added an api to the web server simple to add / remove mime types from scripts.

This commit is contained in:
Relintai 2022-07-24 18:09:45 +02:00
parent e0b2f048c2
commit 09acb9bfeb
2 changed files with 13 additions and 0 deletions

View File

@ -105,6 +105,13 @@ void WebServerSimple::set_worker_thread_count(const int val) {
_worker_thread_count = val;
}
void WebServerSimple::add_mime_type(const String &file_extension, const String &mime_type) {
_server->mimes[file_extension] = mime_type;
}
void WebServerSimple::remove_mime_type(const String &file_extension) {
_server->mimes.erase(file_extension);
}
bool WebServerSimple::is_running() const {
return _is_running;
}
@ -262,6 +269,9 @@ void WebServerSimple::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_worker_thread_count", "val"), &WebServerSimple::set_worker_thread_count);
ADD_PROPERTY(PropertyInfo(Variant::INT, "worker_thread_count"), "set_worker_thread_count", "get_worker_thread_count");
ClassDB::bind_method(D_METHOD("add_mime_type", "file_extension", "mime_type"), &WebServerSimple::add_mime_type);
ClassDB::bind_method(D_METHOD("remove_mime_type", "file_extension"), &WebServerSimple::remove_mime_type);
ClassDB::bind_method(D_METHOD("is_running"), &WebServerSimple::is_running);
}

View File

@ -71,6 +71,9 @@ public:
int get_worker_thread_count();
void set_worker_thread_count(const int val);
void add_mime_type(const String &file_extension, const String &mime_type);
void remove_mime_type(const String &file_extension);
bool is_running() const;
void _start();