Open AlecTaylor opened 10 years ago
You must implement your own routing system. In your server handler you have access to the informations about the request (request& req). With a simple "if" condition on the request url you'll be able to echo different things.
Hmm, is there a trick to printing the request URL?
I've tried:
std::cout << "req = " << req;
And:
std::cout << "req = " << std::string(req);
EDIT: Oh, native::http::request::~request()
is private.
EDIT2: I can see the route by returning: res.end(req.url().path());
, however neither req.url().path() == "/foo"
nor strcmp(req.url().path(), "foo")
are working. How do I construct the condition? - Or do I need to construct my own url_obj
?
That's really strange. req.url().path() == "/foo"
should work.
Try playing with this gist to figure out how to route the way you want: https://gist.github.com/tclamb/8172136
How do I work with URL routing in node.native?
E.g.: I want to expose /foo/ and /bar/ to echo different things.