Replace static/dynamic with a single option: route

Kore will automatically detect if a route is a dynamic or static one
so there is no need for the configuration options to differ anymore.
This commit is contained in:
Joris Vink 2019-11-15 08:11:02 +01:00
parent 73757a29d5
commit f6cd16c567
23 changed files with 65 additions and 56 deletions

View File

@ -15,6 +15,6 @@ domain * {
certfile cert/server.pem
certkey cert/key.pem
static / http
static /ftp ftp
route / http
route /ftp ftp
}

View File

@ -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
}

View File

@ -12,5 +12,5 @@ domain * {
certfile cert/server.pem
certkey cert/key.pem
static / page
route / page
}

View File

@ -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

View File

@ -13,5 +13,5 @@ domain * {
certfile cert/server.pem
certkey cert/key.pem
static / page
route / page
}

View File

@ -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 / {

View File

@ -14,6 +14,6 @@ domain 127.0.0.1 {
certfile cert/server.pem
certkey cert/key.pem
static / page
route / page
restrict / post
}

View File

@ -14,5 +14,5 @@ domain 127.0.0.1 {
certfile cert/server.pem
certkey cert/key.pem
static / page
route / page
}

View File

@ -14,6 +14,6 @@ domain * {
certfile cert/server.pem
certkey cert/key.pem
static / homepage
static /v1 v1
route / homepage
route /v1 v1
}

View File

@ -14,5 +14,5 @@ domain * {
certfile cert/server.pem
certkey cert/key.pem
static / page
route / page
}

View File

@ -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
}

View File

@ -19,7 +19,7 @@ domain * {
certfile cert/server.pem
certkey cert/key.pem
static / page
route / page
# The parameters allowed for "/" (GET method).
#

View File

@ -12,5 +12,5 @@ domain * {
certfile cert/server.pem
certkey cert/key.pem
static / page
route / page
}

View File

@ -20,6 +20,6 @@ domain * {
certfile cert/server.pem
certkey cert/key.pem
static / page
static /hello hello
route / page
route /hello hello
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}

View File

@ -15,6 +15,6 @@ domain * {
certfile cert/server.pem
certkey cert/key.pem
static / page
static /subscribe subscribe
route / page
route /subscribe subscribe
}

View File

@ -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

View File

@ -17,5 +17,5 @@ domain * {
certfile cert/server.pem
certkey cert/key.pem
static / page
route / page
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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);
}