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

Unlock the full course today

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

Solution: Create an endpoint

Solution: Create an endpoint - C++ Tutorial

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

Start my 1-month free trial

Solution: Create an endpoint

- I hope you had fun with the challenge and got it working. Let's see how I solved it. Remember our programs don't have to look identical in order for both to be valid. Very quickly I created two stings to hold the query paramaters. skipVal and limitVal and then I create two integers, skip and limit and both of these check to see if skipval and limitval, respectively are valid and if so uses stoi to convert the string in to integer. Otherwise the default values are used. And finally I set skip and limit options using skip and limit variables. So let's take a look at this in code. Let's go to Adam Let us find, the api contacts route and so what we're gonna do right at the beginning I'm gonna say auto skipVal equals req, the request object and it's gonna be ur underscore params dot get and we're looking for a query parameter named skip. I'm gonna the same thing auto, limitVal equals let's just be a little lazy and copy this. Alright and change this to limit Then we're gonna have an int…

Contents