Giter VIP home page Giter VIP logo

Comments (3)

jeremieca avatar jeremieca commented on June 9, 2024

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.

from node.native.

AlecTaylor avatar AlecTaylor commented on June 9, 2024

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?

from node.native.

tclamb avatar tclamb commented on June 9, 2024

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

from node.native.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.