fix: handling of {str} or {int} in request

This commit is contained in:
Tobias Reisinger 2020-05-18 13:52:29 +02:00
parent 420bdeb2aa
commit c370ab6fea

View file

@ -260,9 +260,13 @@ router_find_endpoint(const char *uri_str, size_t uri_len, struct mg_str *method_
continue; continue;
} }
if(strcmp(endpoints[i].route[route_part], uri_token) == 0) if(strcmp(endpoints[i].route[route_part], "{str}") == 0)
{ {
endpoints[i].possible_route += 3; endpoints[i].possible_route += 1;
endpoints[i].args[endpoints[i].args_found].type = ENDPOINT_ARG_TYPE_STR;
endpoints[i].args[endpoints[i].args_found].value.v_str = uri_token;
++endpoints[i].args_found;
continue; continue;
} }
if(strcmp(endpoints[i].route[route_part], "{int}") == 0) if(strcmp(endpoints[i].route[route_part], "{int}") == 0)
@ -282,13 +286,9 @@ router_find_endpoint(const char *uri_str, size_t uri_len, struct mg_str *method_
++endpoints[i].args_found; ++endpoints[i].args_found;
continue; continue;
} }
if(strcmp(endpoints[i].route[route_part], "{str}") == 0) if(strcmp(endpoints[i].route[route_part], uri_token) == 0)
{ {
endpoints[i].possible_route += 1; endpoints[i].possible_route += 3;
endpoints[i].args[endpoints[i].args_found].type = ENDPOINT_ARG_TYPE_STR;
endpoints[i].args[endpoints[i].args_found].value.v_str = uri_token;
++endpoints[i].args_found;
continue; continue;
} }
endpoints[i].possible_route = 0; endpoints[i].possible_route = 0;