NeoGraph 0.10.0
A C++17 Graph Agent Engine Library — LangGraph for C++
Loading...
Searching...
No Matches
endpoint.h
Go to the documentation of this file.
1
14#pragma once
15
16#include <string>
17
18namespace neograph::async {
19
25 std::string host;
26 std::string port;
27 std::string prefix;
28 bool tls = false;
29};
30
35inline AsyncEndpoint split_async_endpoint(const std::string& base_url) {
36 AsyncEndpoint out;
37 std::string rest = base_url;
38
39 auto scheme_end = rest.find("://");
40 if (scheme_end != std::string::npos) {
41 std::string scheme = rest.substr(0, scheme_end);
42 out.tls = (scheme == "https");
43 rest = rest.substr(scheme_end + 3);
44 }
45
46 auto path_start = rest.find('/');
47 std::string authority;
48 if (path_start != std::string::npos) {
49 authority = rest.substr(0, path_start);
50 out.prefix = rest.substr(path_start);
51 } else {
52 authority = rest;
53 }
54
55 auto colon = authority.find(':');
56 if (colon != std::string::npos) {
57 out.host = authority.substr(0, colon);
58 out.port = authority.substr(colon + 1);
59 } else {
60 out.host = authority;
61 out.port = out.tls ? "443" : "80";
62 }
63 return out;
64}
65
66} // namespace neograph::async
AsyncEndpoint split_async_endpoint(const std::string &base_url)
Parse a base URL like https://api.openai.com or http://localhost:8080/v1.
Definition endpoint.h:35
Result of decomposing a URL into the pieces async_post needs.
Definition endpoint.h:24