|
|
|
|
@ -29,7 +29,7 @@ int main(int argc, char *argv[]) {
|
|
|
|
|
|
|
|
|
|
HttpServer http_server(http_port, http_threads); |
|
|
|
|
libtorrent::session session; |
|
|
|
|
const auto stats_metrics = libtorrent::session_stats_metrics(); |
|
|
|
|
|
|
|
|
|
http_server.default_resource["GET"] = [](std::shared_ptr<HttpServer::Response> resp, std::shared_ptr<HttpServer::Request> req) { |
|
|
|
|
auto response = http::response(); |
|
|
|
|
response.set_status(http::not_found); |
|
|
|
|
@ -47,10 +47,15 @@ int main(int argc, char *argv[]) {
|
|
|
|
|
http_server.resource["^/session/torrents(\\?.*)?\\/?$"]["GET"] = [&](std::shared_ptr<HttpServer::Response> resp, std::shared_ptr<HttpServer::Request> req) { |
|
|
|
|
tr::session::torrents::get(session, resp, req); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
http_server.resource["^/session/torrents(\\?.*)?\\/?$"]["POST"] = [&](std::shared_ptr<HttpServer::Response> resp, std::shared_ptr<HttpServer::Request> req) { |
|
|
|
|
tr::session::torrents::post(options, session, resp, req); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
http_server.resource["^/session/torrents(\\?.*)?\\/?$"]["DELETE"] = [&](std::shared_ptr<HttpServer::Response> resp, std::shared_ptr<HttpServer::Request> req) { |
|
|
|
|
tr::session::torrents::del(session, resp, req); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
std::thread server_thread([&http_server]() { |
|
|
|
|
http_server.start(); |
|
|
|
|
}); |
|
|
|
|
|