Is it possible to spin up a server to handle a single request?
rr-tom-noble opened this issue · 1 comments
Hi,
I'm trying to implement client-side code to authenticate with an identity provider using an OAuth implicit flow. I've been looking around for a good C++ HTTP library to help with this and found that this library has a really nice API compared to alternatives. Using a client to make the necessary requests seems simple enough, but I've been considering how to use a HTTP server to handle the redirect url.
I was wondering if it's possible to do something like the following:
- Create a HTTP Server
- Block on processing a single request (i.e. to exchange the authorization code for a token)
- Tear down the HTTP Server
Any help would be much appreciated!
@rr-tom-noble I think there are some different ways to do it. The key is how to invoke Server::stop
method properly.
I just added the following example to show the easiest way. (You could also use std::condition_variable
to find timing to call the stop method.)
https://github.com/yhirose/cpp-httplib/blob/master/example/one_time_request.cc
Hope it helps!