audio_trans/cmake-build-debug/drogon_ctl/config.cc

355 lines
26 KiB
C++
Raw Normal View History

2025-04-07 11:31:21 +08:00
//this file is generated by program(drogon_ctl) automatically,don't modify it!
#include "config.h"
#include <drogon/utils/OStringStream.h>
#include <string>
#include <map>
#include <vector>
#include <set>
#include <iostream>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <list>
#include <deque>
#include <queue>
using namespace drogon;
std::string config::genText(const DrTemplateData& config_view_data)
{
drogon::OStringStream config_tmp_stream;
std::string layoutName{""};
config_tmp_stream << "/* This is a JSON format configuration file\n";
config_tmp_stream << " */\n";
config_tmp_stream << "{\n";
config_tmp_stream << " /*\n";
config_tmp_stream << " //ssl:The global SSL settings. \"key\" and \"cert\" are the path to the SSL key and certificate. While\n";
config_tmp_stream << " // \"conf\" is an array of 1 or 2-element tuples that supplies file style options for `SSL_CONF_cmd`.\n";
config_tmp_stream << " \"ssl\": {\n";
config_tmp_stream << " \"cert\": \"../../trantor/trantor/tests/server.pem\",\n";
config_tmp_stream << " \"key\": \"../../trantor/trantor/tests/server.pem\",\n";
config_tmp_stream << " \"conf\": [\n";
config_tmp_stream << " //[\"Options\", \"-SessionTicket\"], \n";
config_tmp_stream << " //[\"Options\", \"Compression\"]\n";
config_tmp_stream << " ]\n";
config_tmp_stream << " },\n";
config_tmp_stream << " \"listeners\": [\n";
config_tmp_stream << " {\n";
config_tmp_stream << " //address: Ip address,0.0.0.0 by default\n";
config_tmp_stream << " \"address\": \"0.0.0.0\",\n";
config_tmp_stream << " //port: Port number\n";
config_tmp_stream << " \"port\": 80,\n";
config_tmp_stream << " //https: If true, use https for security,false by default\n";
config_tmp_stream << " \"https\": false\n";
config_tmp_stream << " },\n";
config_tmp_stream << " {\n";
config_tmp_stream << " \"address\": \"0.0.0.0\",\n";
config_tmp_stream << " \"port\": 443,\n";
config_tmp_stream << " \"https\": true,\n";
config_tmp_stream << " //cert,key: Cert file path and key file path, empty by default,\n";
config_tmp_stream << " //if empty, use the global setting\n";
config_tmp_stream << " \"cert\": \"\",\n";
config_tmp_stream << " \"key\": \"\",\n";
config_tmp_stream << " //use_old_tls: enable the TLS1.0/1.1, false by default\n";
config_tmp_stream << " \"use_old_tls\": false,\n";
config_tmp_stream << " \"ssl_conf\": [\n";
config_tmp_stream << " //[\"MinProtocol\", \"TLSv1.3\"]\n";
config_tmp_stream << " ]\n";
config_tmp_stream << " }\n";
config_tmp_stream << " ],\n";
config_tmp_stream << " \"db_clients\": [\n";
config_tmp_stream << " {\n";
config_tmp_stream << " //name: Name of the client,'default' by default\n";
config_tmp_stream << " //\"name\":\"\",\n";
config_tmp_stream << " //rdbms: Server type, postgresql,mysql or sqlite3, \"postgresql\" by default\n";
config_tmp_stream << " \"rdbms\": \"postgresql\",\n";
config_tmp_stream << " //filename: Sqlite3 db file name\n";
config_tmp_stream << " //\"filename\":\"\",\n";
config_tmp_stream << " //host: Server address,localhost by default\n";
config_tmp_stream << " \"host\": \"127.0.0.1\",\n";
config_tmp_stream << " //port: Server port, 5432 by default\n";
config_tmp_stream << " \"port\": 5432,\n";
config_tmp_stream << " //dbname: Database name\n";
config_tmp_stream << " \"dbname\": \"test\",\n";
config_tmp_stream << " //user: 'postgres' by default\n";
config_tmp_stream << " \"user\": \"\",\n";
config_tmp_stream << " //passwd: '' by default\n";
config_tmp_stream << " \"passwd\": \"\",\n";
config_tmp_stream << " //is_fast: false by default, if it is true, the client is faster but user can't call\n";
config_tmp_stream << " //any synchronous interface of it.\n";
config_tmp_stream << " \"is_fast\": false,\n";
config_tmp_stream << " //client_encoding: The character set used by the client. it is empty string by default which \n";
config_tmp_stream << " //means use the default character set.\n";
config_tmp_stream << " //\"client_encoding\": \"\",\n";
config_tmp_stream << " //number_of_connections: 1 by default, if the 'is_fast' is true, the number is the number of \n";
config_tmp_stream << " //connections per IO thread, otherwise it is the total number of all connections. \n";
config_tmp_stream << " \"number_of_connections\": 1,\n";
config_tmp_stream << " //timeout: -1.0 by default, in seconds, the timeout for executing a SQL query.\n";
config_tmp_stream << " //zero or negative value means no timeout.\n";
config_tmp_stream << " \"timeout\": -1.0,\n";
config_tmp_stream << " //\"auto_batch\": this feature is only available for the PostgreSQL driver(version >= 14.0), see\n";
config_tmp_stream << " // the wiki for more details.\n";
config_tmp_stream << " \"auto_batch\": false\n";
config_tmp_stream << " }\n";
config_tmp_stream << " ],\n";
config_tmp_stream << " \"redis_clients\": [\n";
config_tmp_stream << " {\n";
config_tmp_stream << " //name: Name of the client,'default' by default\n";
config_tmp_stream << " //\"name\":\"\",\n";
config_tmp_stream << " //host: Server IP, 127.0.0.1 by default\n";
config_tmp_stream << " \"host\": \"127.0.0.1\",\n";
config_tmp_stream << " //port: Server port, 6379 by default\n";
config_tmp_stream << " \"port\": 6379,\n";
config_tmp_stream << " //username: '' by default which means 'default' in redis ACL\n";
config_tmp_stream << " \"username\": \"\",\n";
config_tmp_stream << " //passwd: '' by default\n";
config_tmp_stream << " \"passwd\": \"\",\n";
config_tmp_stream << " //db index: 0 by default\n";
config_tmp_stream << " \"db\": 0,\n";
config_tmp_stream << " //is_fast: false by default, if it is true, the client is faster but user can't call\n";
config_tmp_stream << " //any synchronous interface of it.\n";
config_tmp_stream << " \"is_fast\": false,\n";
config_tmp_stream << " //number_of_connections: 1 by default, if the 'is_fast' is true, the number is the number of \n";
config_tmp_stream << " //connections per IO thread, otherwise it is the total number of all connections. \n";
config_tmp_stream << " \"number_of_connections\": 1,\n";
config_tmp_stream << " //timeout: -1.0 by default, in seconds, the timeout for executing a command.\n";
config_tmp_stream << " //zero or negative value means no timeout.\n";
config_tmp_stream << " \"timeout\": -1.0\n";
config_tmp_stream << " }\n";
config_tmp_stream << " ],*/\n";
config_tmp_stream << " \"app\": {\n";
config_tmp_stream << " //number_of_threads: The number of IO threads, 1 by default, if the value is set to 0, the number of threads\n";
config_tmp_stream << " //is the number of CPU cores\n";
config_tmp_stream << " \"number_of_threads\": 1,\n";
config_tmp_stream << " //enable_session: False by default\n";
config_tmp_stream << " \"enable_session\": false,\n";
config_tmp_stream << " \"session_timeout\": 0,\n";
config_tmp_stream << " //string value of SameSite attribute of the Set-Cookie HTTP respone header\n";
config_tmp_stream << " //valid value is either 'Null' (default), 'Lax', 'Strict' or 'None'\n";
config_tmp_stream << " \"session_same_site\" : \"Null\",\n";
config_tmp_stream << " //document_root: Root path of HTTP document, defaut path is ./\n";
config_tmp_stream << " \"document_root\": \"./\",\n";
config_tmp_stream << " //home_page: Set the HTML file of the home page, the default value is \"index.html\"\n";
config_tmp_stream << " //If there isn't any handler registered to the path \"/\", the home page file in the \"document_root\" is send to clients as a response\n";
config_tmp_stream << " //to the request for \"/\".\n";
config_tmp_stream << " \"home_page\": \"index.html\",\n";
config_tmp_stream << " //use_implicit_page: enable implicit pages if true, true by default\n";
config_tmp_stream << " \"use_implicit_page\": true,\n";
config_tmp_stream << " //implicit_page: Set the file which would the server access in a directory that a user accessed.\n";
config_tmp_stream << " //For example, by default, http://localhost/a-directory resolves to http://localhost/a-directory/index.html.\n";
config_tmp_stream << " \"implicit_page\": \"index.html\",\n";
config_tmp_stream << " //static_file_headers: Headers for static files\n";
config_tmp_stream << " /*\"static_file_headers\": [\n";
config_tmp_stream << " {\n";
config_tmp_stream << " \"name\": \"field-name\",\n";
config_tmp_stream << " \"value\": \"field-value\"\n";
config_tmp_stream << " }\n";
config_tmp_stream << " ],*/\n";
config_tmp_stream << " //upload_path: The path to save the uploaded file. \"uploads\" by default. \n";
config_tmp_stream << " //If the path isn't prefixed with /, ./ or ../,\n";
config_tmp_stream << " //it is relative path of document_root path\n";
config_tmp_stream << " \"upload_path\": \"uploads\",\n";
config_tmp_stream << " /* file_types:\n";
config_tmp_stream << " * HTTP download file types,The file types supported by drogon\n";
config_tmp_stream << " * by default are \"html\", \"js\", \"css\", \"xml\", \"xsl\", \"txt\", \"svg\",\n";
config_tmp_stream << " * \"ttf\", \"otf\", \"woff2\", \"woff\" , \"eot\", \"png\", \"jpg\", \"jpeg\",\n";
config_tmp_stream << " * \"gif\", \"bmp\", \"ico\", \"icns\", etc. */\n";
config_tmp_stream << " \"file_types\": [\n";
config_tmp_stream << " \"gif\",\n";
config_tmp_stream << " \"png\",\n";
config_tmp_stream << " \"jpg\",\n";
config_tmp_stream << " \"js\",\n";
config_tmp_stream << " \"css\",\n";
config_tmp_stream << " \"html\",\n";
config_tmp_stream << " \"ico\",\n";
config_tmp_stream << " \"swf\",\n";
config_tmp_stream << " \"xap\",\n";
config_tmp_stream << " \"apk\",\n";
config_tmp_stream << " \"cur\",\n";
config_tmp_stream << " \"xml\"\n";
config_tmp_stream << " ],\n";
config_tmp_stream << " // mime: A dictionary that extends the internal MIME type support. Maps extensions into new MIME types\n";
config_tmp_stream << " // note: This option only adds MIME to the sever. `file_types` above have to be set for the server to serve them.\n";
config_tmp_stream << " \"mime\": {\n";
config_tmp_stream << " // \"text/markdown\": \"md\",\n";
config_tmp_stream << " // \"text/gemini\": [\"gmi\", \"gemini\"]\n";
config_tmp_stream << " },\n";
config_tmp_stream << " //locations: An array of locations of static files for GET requests.\n";
config_tmp_stream << " \"locations\": [\n";
config_tmp_stream << " {\n";
config_tmp_stream << " //uri_prefix: The URI prefix of the location prefixed with \"/\", the default value is \"\" that disables the location.\n";
config_tmp_stream << " //\"uri_prefix\": \"/.well-known/acme-challenge/\",\n";
config_tmp_stream << " //default_content_type: The default content type of the static files without\n";
config_tmp_stream << " //an extension. empty string by default.\n";
config_tmp_stream << " \"default_content_type\": \"text/plain\",\n";
config_tmp_stream << " //alias: The location in file system, if it is prefixed with \"/\", it \n";
config_tmp_stream << " //presents an absolute path, otherwise it presents a relative path to \n";
config_tmp_stream << " //the document_root path. \n";
config_tmp_stream << " //The default value is \"\" which means use the document root path as the location base path.\n";
config_tmp_stream << " \"alias\": \"\",\n";
config_tmp_stream << " //is_case_sensitive: indicates whether the URI prefix is case sensitive.\n";
config_tmp_stream << " \"is_case_sensitive\": false,\n";
config_tmp_stream << " //allow_all: true by default. If it is set to false, only static files with a valid extension can be accessed.\n";
config_tmp_stream << " \"allow_all\": true,\n";
config_tmp_stream << " //is_recursive: true by default. If it is set to false, files in sub directories can't be accessed.\n";
config_tmp_stream << " \"is_recursive\": true,\n";
config_tmp_stream << " //filters: string array, the filters applied to the location.\n";
config_tmp_stream << " \"filters\": []\n";
config_tmp_stream << " }\n";
config_tmp_stream << " ],\n";
config_tmp_stream << " //max_connections: maximum number of connections, 100000 by default\n";
config_tmp_stream << " \"max_connections\": 100000,\n";
config_tmp_stream << " //max_connections_per_ip: maximum number of connections per clinet, 0 by default which means no limit\n";
config_tmp_stream << " \"max_connections_per_ip\": 0,\n";
config_tmp_stream << " //Load_dynamic_views: False by default, when set to true, drogon\n";
config_tmp_stream << " //compiles and loads dynamically \"CSP View Files\" in directories defined\n";
config_tmp_stream << " //by \"dynamic_views_path\"\n";
config_tmp_stream << " \"load_dynamic_views\": false,\n";
config_tmp_stream << " //dynamic_views_path: If the path isn't prefixed with /, ./ or ../,\n";
config_tmp_stream << " //it is relative path of document_root path\n";
config_tmp_stream << " \"dynamic_views_path\": [\n";
config_tmp_stream << " \"./views\"\n";
config_tmp_stream << " ],\n";
config_tmp_stream << " //dynamic_views_output_path: Default by an empty string which means the output path of source \n";
config_tmp_stream << " //files is the path where the csp files locate. If the path isn't prefixed with /, it is relative \n";
config_tmp_stream << " //path of the current working directory.\n";
config_tmp_stream << " \"dynamic_views_output_path\": \"\",\n";
config_tmp_stream << " //json_parser_stack_limit: 1000 by default, the maximum number of stack depth when reading a json string by the jsoncpp library.\n";
config_tmp_stream << " \"json_parser_stack_limit\": 1000,\n";
config_tmp_stream << " //enable_unicode_escaping_in_json: true by default, enable unicode escaping in json.\n";
config_tmp_stream << " \"enable_unicode_escaping_in_json\": true,\n";
config_tmp_stream << " //float_precision_in_json: set precision of float number in json. \n";
config_tmp_stream << " \"float_precision_in_json\": {\n";
config_tmp_stream << " //precision: 0 by default, 0 means use the default precision of the jsoncpp lib. \n";
config_tmp_stream << " \"precision\": 0,\n";
config_tmp_stream << " //precision_type: must be \"significant\" or \"decimal\", defaults to \"significant\" that means \n";
config_tmp_stream << " //setting max number of significant digits in string, \"decimal\" means setting max number of \n";
config_tmp_stream << " //digits after \".\" in string\n";
config_tmp_stream << " \"precision_type\": \"significant\"\n";
config_tmp_stream << " },\n";
config_tmp_stream << " //log: Set log output, drogon output logs to stdout by default\n";
config_tmp_stream << " \"log\": {\n";
config_tmp_stream << " //log_path: Log file path,empty by default,in which case,logs are output to the stdout\n";
config_tmp_stream << " //\"log_path\": \"./\",\n";
config_tmp_stream << " //logfile_base_name: Log file base name,empty by default which means drogon names logfile as\n";
config_tmp_stream << " //drogon.log ...\n";
config_tmp_stream << " \"logfile_base_name\": \"\",\n";
config_tmp_stream << " //log_size_limit: 100000000 bytes by default,\n";
config_tmp_stream << " //When the log file size reaches \"log_size_limit\", the log file is switched.\n";
config_tmp_stream << " \"log_size_limit\": 100000000,\n";
config_tmp_stream << " //log_level: \"DEBUG\" by default,options:\"TRACE\",\"DEBUG\",\"INFO\",\"WARN\"\n";
config_tmp_stream << " //The TRACE level is only valid when built in DEBUG mode.\n";
config_tmp_stream << " \"log_level\": \"DEBUG\",\n";
config_tmp_stream << " //display_local_time: false by default, if true, the log time is displayed in local time\n";
config_tmp_stream << " \"display_local_time\": false\n";
config_tmp_stream << " },\n";
config_tmp_stream << " //run_as_daemon: False by default\n";
config_tmp_stream << " \"run_as_daemon\": false,\n";
config_tmp_stream << " //handle_sig_term: True by default\n";
config_tmp_stream << " \"handle_sig_term\": true,\n";
config_tmp_stream << " //relaunch_on_error: False by default, if true, the program will be restart by the parent after exiting;\n";
config_tmp_stream << " \"relaunch_on_error\": false,\n";
config_tmp_stream << " //use_sendfile: True by default, if true, the program \n";
config_tmp_stream << " //uses sendfile() system-call to send static files to clients;\n";
config_tmp_stream << " \"use_sendfile\": true,\n";
config_tmp_stream << " //use_gzip: True by default, use gzip to compress the response body's content;\n";
config_tmp_stream << " \"use_gzip\": true,\n";
config_tmp_stream << " //use_brotli: False by default, use brotli to compress the response body's content;\n";
config_tmp_stream << " \"use_brotli\": false,\n";
config_tmp_stream << " //static_files_cache_time: 5 (seconds) by default, the time in which the static file response is cached,\n";
config_tmp_stream << " //0 means cache forever, the negative value means no cache\n";
config_tmp_stream << " \"static_files_cache_time\": 5,\n";
config_tmp_stream << " //simple_controllers_map: Used to configure mapping from path to simple controller\n";
config_tmp_stream << " \"simple_controllers_map\": [\n";
config_tmp_stream << " {\n";
config_tmp_stream << " \"path\": \"/path/name\",\n";
config_tmp_stream << " \"controller\": \"controllerClassName\",\n";
config_tmp_stream << " \"http_methods\": [\n";
config_tmp_stream << " \"get\",\n";
config_tmp_stream << " \"post\"\n";
config_tmp_stream << " ],\n";
config_tmp_stream << " \"filters\": [\n";
config_tmp_stream << " \"FilterClassName\"\n";
config_tmp_stream << " ]\n";
config_tmp_stream << " }\n";
config_tmp_stream << " ],\n";
config_tmp_stream << " //idle_connection_timeout: Defaults to 60 seconds, the lifetime \n";
config_tmp_stream << " //of the connection without read or write\n";
config_tmp_stream << " \"idle_connection_timeout\": 60,\n";
config_tmp_stream << " //server_header_field: Set the 'Server' header field in each response sent by drogon,\n";
config_tmp_stream << " //empty string by default with which the 'Server' header field is set to \"Server: drogon/version string\\r\\n\"\n";
config_tmp_stream << " \"server_header_field\": \"\",\n";
config_tmp_stream << " //enable_server_header: Set true to force drogon to add a 'Server' header to each HTTP response. The default \n";
config_tmp_stream << " //value is true.\n";
config_tmp_stream << " \"enable_server_header\": true,\n";
config_tmp_stream << " //enable_date_header: Set true to force drogon to add a 'Date' header to each HTTP response. The default \n";
config_tmp_stream << " //value is true.\n";
config_tmp_stream << " \"enable_date_header\": true,\n";
config_tmp_stream << " //keepalive_requests: Set the maximum number of requests that can be served through one keep-alive connection. \n";
config_tmp_stream << " //After the maximum number of requests are made, the connection is closed.\n";
config_tmp_stream << " //The default value of 0 means no limit.\n";
config_tmp_stream << " \"keepalive_requests\": 0,\n";
config_tmp_stream << " //pipelining_requests: Set the maximum number of unhandled requests that can be cached in pipelining buffer. \n";
config_tmp_stream << " //After the maximum number of requests are made, the connection is closed.\n";
config_tmp_stream << " //The default value of 0 means no limit.\n";
config_tmp_stream << " \"pipelining_requests\": 0,\n";
config_tmp_stream << " //gzip_static: If it is set to true, when the client requests a static file, drogon first finds the compressed \n";
config_tmp_stream << " //file with the extension \".gz\" in the same path and send the compressed file to the client.\n";
config_tmp_stream << " //The default value of gzip_static is true.\n";
config_tmp_stream << " \"gzip_static\": true,\n";
config_tmp_stream << " //br_static: If it is set to true, when the client requests a static file, drogon first finds the compressed \n";
config_tmp_stream << " //file with the extension \".br\" in the same path and send the compressed file to the client.\n";
config_tmp_stream << " //The default value of br_static is true.\n";
config_tmp_stream << " \"br_static\": true,\n";
config_tmp_stream << " //client_max_body_size: Set the maximum body size of HTTP requests received by drogon. The default value is \"1M\".\n";
config_tmp_stream << " //One can set it to \"1024\", \"1k\", \"10M\", \"1G\", etc. Setting it to \"\" means no limit.\n";
config_tmp_stream << " \"client_max_body_size\": \"1M\",\n";
config_tmp_stream << " //max_memory_body_size: Set the maximum body size in memory of HTTP requests received by drogon. The default value is \"64K\" bytes.\n";
config_tmp_stream << " //If the body size of a HTTP request exceeds this limit, the body is stored to a temporary file for processing.\n";
config_tmp_stream << " //Setting it to \"\" means no limit.\n";
config_tmp_stream << " \"client_max_memory_body_size\": \"64K\",\n";
config_tmp_stream << " //client_max_websocket_message_size: Set the maximum size of messages sent by WebSocket client. The default value is \"128K\".\n";
config_tmp_stream << " //One can set it to \"1024\", \"1k\", \"10M\", \"1G\", etc. Setting it to \"\" means no limit.\n";
config_tmp_stream << " \"client_max_websocket_message_size\": \"128K\",\n";
config_tmp_stream << " //reuse_port: Defaults to false, users can run multiple processes listening on the same port at the same time.\n";
config_tmp_stream << " \"reuse_port\": false,\n";
config_tmp_stream << " // enabled_compresed_request: Defaults to false. If true the server will automatically decompress compressed request bodies.\n";
config_tmp_stream << " // Currently only gzip and br are supported. Note: max_memory_body_size and max_body_size applies twice for compressed requests.\n";
config_tmp_stream << " // Once when receiving and once when decompressing. i.e. if the decompressed body is larger than max_body_size, the request\n";
config_tmp_stream << " // will be rejected.\n";
config_tmp_stream << " \"enabled_compresed_request\": false\n";
config_tmp_stream << " },\n";
config_tmp_stream << " //plugins: Define all plugins running in the application\n";
config_tmp_stream << " \"plugins\": [\n";
config_tmp_stream << " {\n";
config_tmp_stream << " //name: The class name of the plugin\n";
config_tmp_stream << " //\"name\": \"drogon::plugin::SecureSSLRedirector\",\n";
config_tmp_stream << " //dependencies: Plugins that the plugin depends on. It can be commented out\n";
config_tmp_stream << " \"dependencies\": [],\n";
config_tmp_stream << " //config: The configuration of the plugin. This json object is the parameter to initialize the plugin.\n";
config_tmp_stream << " //It can be commented out\n";
config_tmp_stream << " \"config\": {\n";
config_tmp_stream << " \"ssl_redirect_exempt\": [\n";
config_tmp_stream << " \".*\\\\.jpg\"\n";
config_tmp_stream << " ],\n";
config_tmp_stream << " \"secure_ssl_host\": \"localhost:8849\"\n";
config_tmp_stream << " }\n";
config_tmp_stream << " }\n";
config_tmp_stream << " ],\n";
config_tmp_stream << " //custom_config: custom configuration for users. This object can be get by the app().getCustomConfig() method. \n";
config_tmp_stream << " \"custom_config\": {}\n";
config_tmp_stream << "}\n";
if(layoutName.empty())
{
std::string ret{std::move(config_tmp_stream.str())};
return ret;
}else
{
auto templ = DrTemplateBase::newTemplate(layoutName);
if(!templ) return "";
HttpViewData data = config_view_data;
auto str = std::move(config_tmp_stream.str());
if(!str.empty() && str[str.length()-1] == '\n') str.resize(str.length()-1);
data[""] = std::move(str);
return templ->genText(data);
}
}