Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <unistd.h>
- #include <cstdio>
- #include <csignal>
- #include "webserver.hpp"
- void handle_signal(int)
- {
- printf("Caught signal\n");
- }
- void myfunc(server * s, server::client_context ctx)
- {
- printf("Recieved request for \"%s\"\n", ctx->get_request_url().c_str());
- ctx->queue_response(s, http::code::ok, "OK", "It works!\n");
- }
- int main()
- {
- signal(SIGINT, handle_signal);
- server s;
- printf("adding\n");
- s.add_listening_address("localhost", 10001);
- printf("removing\n");
- s.remove_listening_address("localhost", 10001);
- fflush(stdout);
- std::this_thread::sleep_for(std::chrono::seconds(1));
- printf("adding next set\n");
- s.add_listening_address("", 10001);
- s.add_endpoint("/metrics", myfunc);
- pause();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement