Thread: Router Constructor Design Advice

  1. #1
    Registered User MutantJohn's Avatar
    Join Date
    Feb 2013

    Router Constructor Design Advice

    Hey guys,

    I'm really getting into the cpprestsdk. Now, one thing I need to build for this to be successful is a router.

    Their `http_req` class has a very nice `relative_uri` function which I can use and I know how to split a string by a special character so I was going to internally implement this as something like a prefix tree.

    Regardless of that, what's a good way of initially constructing this router? Ideally I'd like construction to handle the mapping between a URI and a dedicated handler, in this case a handler is just a simple callable object that takes a http request.

    Should I use a vector of pairs of uris and callables? Is it okay to force the user to basically type:

  2. #2
    Registered User MutantJohn's Avatar
    Join Date
    Feb 2013
    Nevermind, I guess this thread is probably gonna `join` pretty soon XD

    Basically, I've decided to just use something like:
    router.route("/api/users/rawr", http_method, some_callable);
    router.get("/api/users/photos", some_other_callable);
    And then to break up route-building, functions can simply just take a router by reference and mutate it there.

    I've also decided on using a trie-like approach for the routing scheme and am excited to fold in everything I've learned doing Node into C++

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Advice on class design.
    By manasij7479 in forum C++ Programming
    Replies: 13
    Last Post: 01-25-2013, 12:52 PM
  2. Design guidelines advice - IRC Bot class
    By IceDane in forum C# Programming
    Replies: 2
    Last Post: 12-05-2008, 01:21 AM
  3. some design advice
    By viaxd in forum Game Programming
    Replies: 0
    Last Post: 08-03-2006, 06:08 AM
  4. need advice with class design
    By DonFiasco in forum C++ Programming
    Replies: 4
    Last Post: 12-27-2004, 08:29 PM
  5. Web Design advice
    By sean in forum A Brief History of
    Replies: 4
    Last Post: 04-01-2003, 04:34 PM

Tags for this Thread