Motion Master 6.0.0-alpha.86
Next-generation motion control software
Loading...
Searching...
No Matches
http_client.h
Go to the documentation of this file.
1#pragma once
2
3#include <chrono>
4#include <expected>
5#include <string>
6
17
18namespace mm::net {
19
26struct Response {
27 int status = 0;
28 std::string body;
29};
30
36std::expected<Response, std::string> httpGet(const std::string& url,
37 std::chrono::seconds timeout = std::chrono::seconds{
38 30});
39
46std::expected<Response, std::string> httpPost(const std::string& url, const std::string& body,
47 const std::string& contentType,
48 std::chrono::seconds timeout = std::chrono::seconds{
49 30});
50
59 public:
60 HttpGlobal();
62 HttpGlobal(const HttpGlobal&) = delete;
63 HttpGlobal& operator=(const HttpGlobal&) = delete;
66};
67
68} // namespace mm::net
Holds libcurl's process-wide state for the lifetime of one instance.
Definition http_client.h:58
HttpGlobal(HttpGlobal &&)=delete
~HttpGlobal()
Definition http_client.cc:97
HttpGlobal & operator=(const HttpGlobal &)=delete
HttpGlobal & operator=(HttpGlobal &&)=delete
HttpGlobal()
Definition http_client.cc:95
HttpGlobal(const HttpGlobal &)=delete
Definition http_client.cc:10
std::expected< Response, std::string > httpPost(const std::string &url, const std::string &body, const std::string &contentType, std::chrono::seconds timeout)
Performs a blocking POST.
Definition http_client.cc:69
std::expected< Response, std::string > httpGet(const std::string &url, std::chrono::seconds timeout)
Performs a blocking GET.
Definition http_client.cc:57
std::chrono::milliseconds timeout
Definition somanet_procedures.cc:438
What the server answered.
Definition http_client.h:26
std::string body
Response body, however long, exactly as received.
Definition http_client.h:28
int status
HTTP status code, as the server sent it.
Definition http_client.h:27