-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Roll The Dice Getting Started for C++ #3345
Comments
Hi @svrnm, I would like to work on this! I just need to figure out a few things |
@Akhaled19 that's great to hear, thank you! To provide you with some help, here are a few pointers:
#include "oatpp/web/server/HttpConnectionHandler.hpp"
#include "oatpp/network/Server.hpp"
#include "oatpp/network/tcp/server/ConnectionProvider.hpp"
class Handler : public oatpp::web::server::HttpRequestHandler {
public:
std::shared_ptr<OutgoingResponse> handle(const std::shared_ptr<IncomingRequest>& request) override {
std::string response = std::to_string(1 + (std::rand() % 6));
return ResponseFactory::createResponse(Status::CODE_200, response);
}
};
void run() {
auto router = oatpp::web::server::HttpRouter::createShared();
router->route("GET", "/rolldice", std::make_shared<Handler>());
auto connectionHandler = oatpp::web::server::HttpConnectionHandler::createShared(router);
auto connectionProvider = oatpp::network::tcp::server::ConnectionProvider::createShared({"localhost", 8000, oatpp::network::Address::IP_4});
oatpp::network::Server server(connectionProvider, connectionHandler);
OATPP_LOGI("MyApp", "Server running on port %s", connectionProvider->getProperty("port").getData());
server.run();
}
int main() {
oatpp::base::Environment::init();
run();
oatpp::base::Environment::destroy();
return 0;
} |
@svrnm thank you for the helpful pointers! |
@Akhaled19 sure, let us know if you need any more help and don't hesitate to raise your PR early to get feedback! |
Hi @svrnm I managed to get the app up and running but I'm having a hard time linking OpenTelemetry with my oatpp Application. I'm new to cmake. Here is what my CMakeLists.txt file looks like |
@Akhaled19, if you share the work you have done so far in textual form (snippets here in the comments or even a github repo!), making it easier for us to take a look into what you have tried to accomplish so far. @open-telemetry/cpp-approvers |
Note that C++11 support has been dropped: open-telemetry/opentelemetry-cpp#2342 |
Got it. I will work on the pr |
To complete #2623 we need an updated version of the C++ Getting Started with a "Roll The Dice" app. To simplify things one could use oatpp or drogon or any other C++-based framework.
The text was updated successfully, but these errors were encountered: