From the course: Web Servers and APIs using C++

Unlock the full course today

Join today to access over 22,400 courses taught by industry experts or purchase this course individually.

Parsing the path

Parsing the path - C++ Tutorial

From the course: Web Servers and APIs using C++

Start my 1-month free trial

Parsing the path

- We've already seen Atom incorporate a single parameter into a route handler but what if we need more parameters? That's not a problem. You can use as many parameters as your route needs. Let's return to the contact route handler. Currently, we have a route handler which searches for the contact via a single route parameter, the email address. Let's write another handler, this time passing the first and last names. So, we'll make a copy. And put it right below it. Go ahead and adjust. And now, we're gonna add a second string, so string. And this is gonna be firstname, and the second one is gonna be lastname. Now, we're gonna have to make another change, here, and that is that we need the request and response objects. So, I'm gonna say const request reference req. Response reference res. I need to modify this getView and I'll explain in just one moment why we're gonna modify it but now, we're gonna call it with a res contact. Here, let's add a little space. We're now gonna search for…

Contents