diff --git a/examples/async-curl/conf/async-curl.conf b/examples/async-curl/conf/async-curl.conf index 623ce85..9f7c8fd 100644 --- a/examples/async-curl/conf/async-curl.conf +++ b/examples/async-curl/conf/async-curl.conf @@ -15,6 +15,6 @@ domain * { certfile cert/server.pem certkey cert/key.pem - static / http - static /ftp ftp + route / http + route /ftp ftp } diff --git a/examples/cookies/conf/cookies.conf b/examples/cookies/conf/cookies.conf index faf51fa..34f3dfd 100644 --- a/examples/cookies/conf/cookies.conf +++ b/examples/cookies/conf/cookies.conf @@ -14,7 +14,7 @@ domain * { certfile cert/server.pem certkey cert/key.pem - static / serve_cookies - static /secure serve_cookies - static /vault serve_cookies + route / serve_cookies + route /secure serve_cookies + route /vault serve_cookies } diff --git a/examples/cpp/conf/cpp.conf b/examples/cpp/conf/cpp.conf index b58e43f..9cb58c7 100755 --- a/examples/cpp/conf/cpp.conf +++ b/examples/cpp/conf/cpp.conf @@ -12,5 +12,5 @@ domain * { certfile cert/server.pem certkey cert/key.pem - static / page + route / page } diff --git a/examples/generic/conf/generic.conf b/examples/generic/conf/generic.conf index ceabd4b..18cdcca 100644 --- a/examples/generic/conf/generic.conf +++ b/examples/generic/conf/generic.conf @@ -30,16 +30,16 @@ domain * { certkey cert/key.pem accesslog kore_access.log - static /css/style.css asset_serve_style_css - static / asset_serve_index_html - static /intro.jpg asset_serve_intro_jpg - static /b64test serve_b64test - static /upload serve_file_upload - static /validator serve_validator - static /params-test serve_params_test - static /private serve_private + route /css/style.css asset_serve_style_css + route / asset_serve_index_html + route /intro.jpg asset_serve_intro_jpg + route /b64test serve_b64test + route /upload serve_file_upload + route /validator serve_validator + route /params-test serve_params_test + route /private serve_private - static /private/test asset_serve_private_test_html auth_example + route /private/test asset_serve_private_test_html auth_example params post /params-test { validate test1 v_example diff --git a/examples/headers/conf/headers.conf b/examples/headers/conf/headers.conf index f5d3ac4..feb8267 100755 --- a/examples/headers/conf/headers.conf +++ b/examples/headers/conf/headers.conf @@ -13,5 +13,5 @@ domain * { certfile cert/server.pem certkey cert/key.pem - static / page + route / page } diff --git a/examples/integers/conf/integers.conf b/examples/integers/conf/integers.conf index c4bf63b..0493ff7 100755 --- a/examples/integers/conf/integers.conf +++ b/examples/integers/conf/integers.conf @@ -18,7 +18,7 @@ domain * { certfile cert/server.pem certkey cert/key.pem - static / page + route / page # allowed parameters in the query string for GETs params qs:get / { diff --git a/examples/json/conf/json.conf b/examples/json/conf/json.conf index c7ee1b6..b896c13 100755 --- a/examples/json/conf/json.conf +++ b/examples/json/conf/json.conf @@ -14,6 +14,6 @@ domain 127.0.0.1 { certfile cert/server.pem certkey cert/key.pem - static / page + route / page restrict / post } diff --git a/examples/json_yajl/conf/json_yajl.conf b/examples/json_yajl/conf/json_yajl.conf index 7949a30..29d2c01 100755 --- a/examples/json_yajl/conf/json_yajl.conf +++ b/examples/json_yajl/conf/json_yajl.conf @@ -14,5 +14,5 @@ domain 127.0.0.1 { certfile cert/server.pem certkey cert/key.pem - static / page + route / page } diff --git a/examples/jsonrpc/conf/jsonrpc.conf b/examples/jsonrpc/conf/jsonrpc.conf index d3314e4..c8ff8d9 100644 --- a/examples/jsonrpc/conf/jsonrpc.conf +++ b/examples/jsonrpc/conf/jsonrpc.conf @@ -14,6 +14,6 @@ domain * { certfile cert/server.pem certkey cert/key.pem - static / homepage - static /v1 v1 + route / homepage + route /v1 v1 } diff --git a/examples/memtag/conf/memtag.conf b/examples/memtag/conf/memtag.conf index 1484abe..f981b6c 100644 --- a/examples/memtag/conf/memtag.conf +++ b/examples/memtag/conf/memtag.conf @@ -14,5 +14,5 @@ domain * { certfile cert/server.pem certkey cert/key.pem - static / page + route / page } diff --git a/examples/messaging/conf/messaging.conf b/examples/messaging/conf/messaging.conf index b7be287..f8680ae 100644 --- a/examples/messaging/conf/messaging.conf +++ b/examples/messaging/conf/messaging.conf @@ -13,6 +13,6 @@ domain * { certfile cert/server.pem certkey cert/key.pem - static / page - static /shutdown page_shutdown + route / page + route /shutdown page_shutdown } diff --git a/examples/parameters/conf/parameters.conf b/examples/parameters/conf/parameters.conf index 50d02e0..c51798c 100755 --- a/examples/parameters/conf/parameters.conf +++ b/examples/parameters/conf/parameters.conf @@ -19,7 +19,7 @@ domain * { certfile cert/server.pem certkey cert/key.pem - static / page + route / page # The parameters allowed for "/" (GET method). # diff --git a/examples/pgsql-sync/conf/pgsql-sync.conf b/examples/pgsql-sync/conf/pgsql-sync.conf index 783cc88..543c2b4 100644 --- a/examples/pgsql-sync/conf/pgsql-sync.conf +++ b/examples/pgsql-sync/conf/pgsql-sync.conf @@ -12,5 +12,5 @@ domain * { certfile cert/server.pem certkey cert/key.pem - static / page + route / page } diff --git a/examples/pgsql/conf/pgsql.conf b/examples/pgsql/conf/pgsql.conf index 9d3c4e8..faeb3c9 100755 --- a/examples/pgsql/conf/pgsql.conf +++ b/examples/pgsql/conf/pgsql.conf @@ -20,6 +20,6 @@ domain * { certfile cert/server.pem certkey cert/key.pem - static / page - static /hello hello + route / page + route /hello hello } diff --git a/examples/pipe_task/conf/pipe_task.conf b/examples/pipe_task/conf/pipe_task.conf index 2604887..8373aff 100755 --- a/examples/pipe_task/conf/pipe_task.conf +++ b/examples/pipe_task/conf/pipe_task.conf @@ -17,6 +17,6 @@ domain * { certfile cert/server.pem certkey cert/key.pem - static / page - static /connect page_ws_connect + route / page + route /connect page_ws_connect } diff --git a/examples/python-async/conf/python-async.conf b/examples/python-async/conf/python-async.conf index 0f7d644..6d68786 100644 --- a/examples/python-async/conf/python-async.conf +++ b/examples/python-async/conf/python-async.conf @@ -17,12 +17,12 @@ python_import ./src/async_http.py domain * { attach notls - static /queue async_queue - static /lock async_lock - static /proc async_proc + route /queue async_queue + route /lock async_lock + route /proc async_proc - static /socket async_socket - static /socket-test socket_test + route /socket async_socket + route /socket-test socket_test - static /httpclient httpclient + route /httpclient httpclient } diff --git a/examples/python-pgsql/kore.conf b/examples/python-pgsql/kore.conf index ff80efb..3c11b3a 100644 --- a/examples/python-pgsql/kore.conf +++ b/examples/python-pgsql/kore.conf @@ -12,7 +12,7 @@ domain * { certfile cert/server.pem certkey cert/key.pem - static / koreapp.query - static /hello koreapp.hello - static /slow koreapp.slow + route / koreapp.query + route /hello koreapp.hello + route /slow koreapp.slow } diff --git a/examples/sse/conf/sse.conf b/examples/sse/conf/sse.conf index 3a18ae7..e373708 100755 --- a/examples/sse/conf/sse.conf +++ b/examples/sse/conf/sse.conf @@ -15,6 +15,6 @@ domain * { certfile cert/server.pem certkey cert/key.pem - static / page - static /subscribe subscribe + route / page + route /subscribe subscribe } diff --git a/examples/tasks/conf/tasks.conf b/examples/tasks/conf/tasks.conf index 5d912b0..2722628 100644 --- a/examples/tasks/conf/tasks.conf +++ b/examples/tasks/conf/tasks.conf @@ -21,8 +21,8 @@ domain * { certkey cert/key.pem accesslog kore_access.log - static / page_handler - static /post_back post_back + route / page_handler + route /post_back post_back params qs:get / { validate user v_user diff --git a/examples/upload/conf/upload.conf b/examples/upload/conf/upload.conf index 6fab59a..1a73855 100644 --- a/examples/upload/conf/upload.conf +++ b/examples/upload/conf/upload.conf @@ -17,5 +17,5 @@ domain * { certfile cert/server.pem certkey cert/key.pem - static / page + route / page } diff --git a/examples/video_stream/conf/video_stream.conf b/examples/video_stream/conf/video_stream.conf index ee6d954..c44f753 100755 --- a/examples/video_stream/conf/video_stream.conf +++ b/examples/video_stream/conf/video_stream.conf @@ -17,6 +17,6 @@ domain * { certkey cert/key.pem accesslog access.log - static / asset_serve_video_html - dynamic ^/[a-z]*.[a-z0-9]{3}$ video_stream + route / asset_serve_video_html + route ^/[a-z]*.[a-z0-9]{3}$ video_stream } diff --git a/examples/websocket/conf/websocket.conf b/examples/websocket/conf/websocket.conf index 376b74f..228f8d1 100755 --- a/examples/websocket/conf/websocket.conf +++ b/examples/websocket/conf/websocket.conf @@ -21,6 +21,6 @@ domain * { certfile cert/server.pem certkey cert/key.pem - static / page - static /connect page_ws_connect + route / page + route /connect page_ws_connect } diff --git a/src/config.c b/src/config.c index 7e54c71..f292fca 100644 --- a/src/config.c +++ b/src/config.c @@ -107,11 +107,11 @@ static int configure_client_verify(char *); static int configure_client_verify_depth(char *); #if !defined(KORE_NO_HTTP) +static int configure_route(char *); static int configure_filemap(char *); -static int configure_restrict(char *); -static int configure_handler(int, char *); static int configure_static_handler(char *); static int configure_dynamic_handler(char *); +static int configure_restrict(char *); static int configure_accesslog(char *); static int configure_http_header_max(char *); static int configure_http_header_timeout(char *); @@ -186,6 +186,7 @@ static struct { { "python_import", configure_python_import }, #endif #if !defined(KORE_NO_HTTP) + { "route", configure_route}, { "filemap", configure_filemap }, { "static", configure_static_handler }, { "dynamic", configure_dynamic_handler }, @@ -971,35 +972,43 @@ configure_attach(char *name) static int configure_static_handler(char *options) { - return (configure_handler(HANDLER_TYPE_STATIC, options)); + kore_log(LOG_NOTICE, "static keyword removed, use route instead"); + return (KORE_RESULT_ERROR); } static int configure_dynamic_handler(char *options) { - return (configure_handler(HANDLER_TYPE_DYNAMIC, options)); + kore_log(LOG_NOTICE, "dynamic keyword removed, use route instead"); + return (KORE_RESULT_ERROR); } static int -configure_handler(int type, char *options) +configure_route(char *options) { + int type; char *argv[4]; if (current_domain == NULL) { - printf("page handler not specified in domain context\n"); + printf("route not specified in domain context\n"); return (KORE_RESULT_ERROR); } kore_split_string(options, " ", argv, 4); if (argv[0] == NULL || argv[1] == NULL) { - printf("missing parameters for page handler\n"); + printf("missing parameters for route \n"); return (KORE_RESULT_ERROR); } + if (*argv[0] == '/') + type = HANDLER_TYPE_STATIC; + else + type = HANDLER_TYPE_DYNAMIC; + if (!kore_module_handler_new(current_domain, argv[0], argv[1], argv[2], type)) { - printf("cannot create handler for %s\n", argv[0]); + printf("cannot create route for %s\n", argv[0]); return (KORE_RESULT_ERROR); }