Ejemplo n.º 1
0
END_TEST























START_TEST(test_route_cmp)
{
    route *r1 = r3_route_create("/blog/post");
    match_entry * m = match_entry_create("/blog/post");

    fail_if( r3_route_cmp(r1, m) == -1, "should match");

    r1->request_method = METHOD_GET;
    m->request_method = METHOD_GET;
    fail_if( r3_route_cmp(r1, m) == -1, "should match");

    r1->request_method = METHOD_GET;
    m->request_method = METHOD_POST;
    fail_if( r3_route_cmp(r1, m) == 0, "should be different");

    r1->request_method = METHOD_GET;
    m->request_method = METHOD_POST | METHOD_GET;
    fail_if( r3_route_cmp(r1, m) == -1, "should match");

    r3_route_free(r1);
    match_entry_free(m);
}
Ejemplo n.º 2
0
Archivo: node.c Proyecto: lucemia/r3
route * r3_tree_match_route(const node *tree, const match_entry * entry) {
    node *n;
    n = r3_tree_match_entry(tree, entry);
    if (n->routes && n->route_len > 0) {
        int i;
        for (i = 0; i < n->route_len ; i++ ) {
            if ( r3_route_cmp(n->routes[i], entry) == 0 ) {
                return n->routes[i];
            }
        }
    }
    return NULL;
}
Ejemplo n.º 3
0
Archivo: node.c Proyecto: RickySu/r3
route * r3_tree_match_route(const node *tree, match_entry * entry) {
    node *n;
    int i;
    n = r3_tree_match_entry(tree, entry);
    if (n && n->routes && n->route_len > 0) {
        for (i = n->route_len; i--; ) {
            if ( r3_route_cmp(n->routes[i], entry) == 0 ) {
                return n->routes[i];
            }
        }
    }
    return NULL;
}