mongoose-cpp icon indicating copy to clipboard operation
mongoose-cpp copied to clipboard

Bug: regular expression matching doesn't work

Open rans1 opened this issue 11 years ago • 1 comments

hi

the fix of url regular expression matching doesn't work in this project. i have tracked the issue & it seems it doesn't work because of:

bool Controller::handles(string method, string url) { string key = method + ":" + url;

    return (routes.find(key) != routes.end()); // << routes is a map 

}

as seen in the code routes is a map & when you try to find a matched url you failed this function is called before the method:

Response *Controller::process(Request &request) { Response *response = NULL; map<string, RequestHandlerBase *>::iterator it; for (it=routes.begin(); it!=routes.end(); it++) { if (request.match(it->first)){ response = it->second->process(request); break; } } return response; }

which find a mtach by iterating the map & call request.match

rans1 avatar Jan 28 '14 18:01 rans1

Hello,

I must confess I didn't maintained the regexp matching when I moved to the new mongoose (I had to change mongoose a little to tel if a route is handled or not). We should also test for matching in handles right now, this is indeed an issue.

Gregwar avatar Jan 28 '14 18:01 Gregwar