mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2024-12-24 04:46:48 +01:00
Added a new RedirectWebPage WebNode.
This commit is contained in:
parent
16fda02f48
commit
ed92564261
@ -59,6 +59,8 @@ sources = [
|
||||
"nodes/paged_article/paged_article.cpp",
|
||||
"nodes/paged_article/paged_articles.cpp",
|
||||
#"nodes/paged_article/paged_articles_md_index.cpp",
|
||||
|
||||
"nodes/redirect/redirect_web_page.cpp",
|
||||
]
|
||||
|
||||
if ARGUMENTS.get('custom_modules_shared', 'no') == 'yes':
|
||||
|
@ -74,6 +74,8 @@ def get_doc_classes():
|
||||
"PagedArticle",
|
||||
"PagedArticles",
|
||||
"PagedArticlesMDIndex",
|
||||
|
||||
"RedirectWebPage",
|
||||
]
|
||||
|
||||
|
||||
|
40
modules/web/nodes/redirect/redirect_web_page.cpp
Normal file
40
modules/web/nodes/redirect/redirect_web_page.cpp
Normal file
@ -0,0 +1,40 @@
|
||||
#include "redirect_web_page.h"
|
||||
|
||||
#include "../../http/http_server_enums.h"
|
||||
#include "../../http/web_server_request.h"
|
||||
#include "core/os/file_access.h"
|
||||
|
||||
String RedirectWebPage::get_redirect_path() {
|
||||
return _redirect_path;
|
||||
}
|
||||
void RedirectWebPage::set_redirect_path(const String &val) {
|
||||
_redirect_path = val;
|
||||
}
|
||||
|
||||
int RedirectWebPage::get_code() {
|
||||
return _code;
|
||||
}
|
||||
void RedirectWebPage::set_code(const int val) {
|
||||
_code = val;
|
||||
}
|
||||
|
||||
void RedirectWebPage::_handle_request(Ref<WebServerRequest> request) {
|
||||
request->send_redirect(_redirect_path, static_cast<HTTPServerEnums::HTTPStatusCode>(_code));
|
||||
}
|
||||
|
||||
RedirectWebPage::RedirectWebPage() {
|
||||
_code = 302;
|
||||
}
|
||||
|
||||
RedirectWebPage::~RedirectWebPage() {
|
||||
}
|
||||
|
||||
void RedirectWebPage::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_redirect_path"), &RedirectWebPage::get_redirect_path);
|
||||
ClassDB::bind_method(D_METHOD("set_redirect_path", "val"), &RedirectWebPage::set_redirect_path);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::STRING, "redirect_path"), "set_redirect_path", "get_redirect_path");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_code"), &RedirectWebPage::get_code);
|
||||
ClassDB::bind_method(D_METHOD("set_code", "val"), &RedirectWebPage::set_code);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "code"), "set_code", "get_code");
|
||||
}
|
32
modules/web/nodes/redirect/redirect_web_page.h
Normal file
32
modules/web/nodes/redirect/redirect_web_page.h
Normal file
@ -0,0 +1,32 @@
|
||||
#ifndef REDIRECT_WEB_PAGE_H
|
||||
#define REDIRECT_WEB_PAGE_H
|
||||
|
||||
#include "core/ustring.h"
|
||||
|
||||
#include "../../http/web_node.h"
|
||||
|
||||
class WebServerRequest;
|
||||
|
||||
class RedirectWebPage : public WebNode {
|
||||
GDCLASS(RedirectWebPage, WebNode);
|
||||
|
||||
public:
|
||||
String get_redirect_path();
|
||||
void set_redirect_path(const String &val);
|
||||
|
||||
int get_code();
|
||||
void set_code(const int val);
|
||||
|
||||
void _handle_request(Ref<WebServerRequest> request);
|
||||
|
||||
RedirectWebPage();
|
||||
~RedirectWebPage();
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
String _redirect_path;
|
||||
int _code;
|
||||
};
|
||||
|
||||
#endif
|
@ -60,6 +60,8 @@ SOFTWARE.
|
||||
#include "nodes/paged_article/paged_articles.h"
|
||||
//#include "nodes/paged_article/paged_articles_md_index.h"
|
||||
|
||||
#include "nodes/redirect/redirect_web_page.h"
|
||||
|
||||
void register_web_types() {
|
||||
ClassDB::register_class<_HTMLBuilder>();
|
||||
ClassDB::register_class<_HTMLTag>();
|
||||
@ -122,6 +124,8 @@ void register_web_types() {
|
||||
ClassDB::register_class<PagedArticle>();
|
||||
ClassDB::register_class<PagedArticles>();
|
||||
//ClassDB::register_class<PagedArticlesMDIndex>();
|
||||
|
||||
ClassDB::register_class<RedirectWebPage>();
|
||||
}
|
||||
|
||||
void unregister_web_types() {
|
||||
|
Loading…
Reference in New Issue
Block a user