This commit is contained in:
@@ -45,12 +45,11 @@ bool found_route(restd_server_t *server, const char *method, const char *path)
|
||||
while (hooks->getnext(hooks, &obj, false) == true)
|
||||
{
|
||||
restd_hook_t *hook = (restd_hook_t *)obj.data;
|
||||
if (hook->method && method && strcmp(hook->method, method)==0)
|
||||
if (hook->method && method && strcmp(hook->method, method) == 0)
|
||||
{
|
||||
if (hook->path && path && strcmp(hook->path, path)==0)
|
||||
return true;
|
||||
if (hook->path && path && strcmp(hook->path, path) == 0)
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -58,7 +57,7 @@ bool found_route(restd_server_t *server, const char *method, const char *path)
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
bool contain (const char *src, const char *dest, int len)
|
||||
bool contain(const char *src, const char *dest, int len)
|
||||
{
|
||||
int len_src, len_dest;
|
||||
int i = 0;
|
||||
@@ -66,6 +65,7 @@ bool contain (const char *src, const char *dest, int len)
|
||||
len_src = strlen(src);
|
||||
if (len_src < len)
|
||||
return false;
|
||||
|
||||
len_dest = strlen(dest);
|
||||
if (len_dest < len)
|
||||
return false;
|
||||
@@ -91,7 +91,7 @@ bool found_special_route(restd_server_t *server, const char *method, const char
|
||||
while (hooks->getnext(hooks, &obj, false) == true)
|
||||
{
|
||||
restd_hook_t *hook = (restd_hook_t *)obj.data;
|
||||
if (hook->method && method && strcmp(hook->method, method)==0)
|
||||
if (hook->method && method && strcmp(hook->method, method) == 0)
|
||||
{
|
||||
if (hook->path && path)
|
||||
{
|
||||
@@ -103,19 +103,19 @@ bool found_special_route(restd_server_t *server, const char *method, const char
|
||||
pos = i;
|
||||
i++;
|
||||
}
|
||||
printf("pos: %d\n", pos);
|
||||
printf("contain: %s\n", contain(hook->path, path, pos)?"TRUE":"FALSE");
|
||||
if ( pos != -1 && contain(hook->path, path, pos))
|
||||
// printf("hook path: %s, path: %s\n", hook->path, path);
|
||||
// printf("pos: %d\n", pos);
|
||||
// printf("contain: %s\n", contain(hook->path, path, pos) ? "TRUE" : "FALSE");
|
||||
if (pos != -1 && contain(hook->path, path, pos))
|
||||
{
|
||||
const char *buffer = &path[i];
|
||||
printf("buffer: %s\n", buffer);
|
||||
const char *buffer = &path[pos];
|
||||
// printf("buffer: <%s>\n", buffer);
|
||||
*id = atoi(buffer);
|
||||
return true;
|
||||
}
|
||||
else if (strcmp(hook->path, path)==0)
|
||||
else if (strcmp(hook->path, path) == 0)
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -170,10 +170,10 @@ TEST("Rest - create access regular route free\t")
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
TEST("Rest - create access regex route free\t")
|
||||
TEST("Rest - create access route with param free\t")
|
||||
{
|
||||
restd_server_t *rest_server;
|
||||
int id = 0;
|
||||
int id = 0;
|
||||
rest_server = restd_server_new();
|
||||
ASSERT_NOT_NULL(rest_server);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user