Replace arguments in URI.
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
id, nickname, nickname_or_id, hashtag, permission_group.
This commit is contained in:
parent
c07fb1db71
commit
2ab0018df9
|
@ -31,7 +31,7 @@ const map<API::endpoint_type,string_view> API::_endpoint_map
|
||||||
{v1::accounts, "/api/v1/accounts"},
|
{v1::accounts, "/api/v1/accounts"},
|
||||||
{v1::accounts_verify_credentials, "/api/v1/accounts/verify/credentials"},
|
{v1::accounts_verify_credentials, "/api/v1/accounts/verify/credentials"},
|
||||||
{v1::accounts_update_credentials, "/api/v1/accounts/update/credentials"},
|
{v1::accounts_update_credentials, "/api/v1/accounts/update/credentials"},
|
||||||
{v1::accounts_id, "/api/v1/accounts/id"},
|
{v1::accounts_id, "/api/v1/accounts/<ID>"},
|
||||||
{v1::accounts_id_statuses, "/api/v1/accounts/<ID>/statuses"},
|
{v1::accounts_id_statuses, "/api/v1/accounts/<ID>/statuses"},
|
||||||
{v1::accounts_id_followers, "/api/v1/accounts/<ID>/followers"},
|
{v1::accounts_id_followers, "/api/v1/accounts/<ID>/followers"},
|
||||||
{v1::accounts_id_following, "/api/v1/accounts/<ID>/following"},
|
{v1::accounts_id_following, "/api/v1/accounts/<ID>/following"},
|
||||||
|
|
|
@ -19,6 +19,8 @@
|
||||||
#include "log.hpp"
|
#include "log.hpp"
|
||||||
#include "version.hpp"
|
#include "version.hpp"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
#include <array>
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
@ -28,6 +30,8 @@ namespace mastodonpp
|
||||||
|
|
||||||
using std::get;
|
using std::get;
|
||||||
using std::holds_alternative;
|
using std::holds_alternative;
|
||||||
|
using std::any_of;
|
||||||
|
using std::array;
|
||||||
using std::atomic;
|
using std::atomic;
|
||||||
using std::uint8_t;
|
using std::uint8_t;
|
||||||
using std::uint16_t;
|
using std::uint16_t;
|
||||||
|
@ -72,6 +76,22 @@ answer_type CURLWrapper::make_request(const http_method &method, string uri,
|
||||||
|
|
||||||
for (const auto ¶m : parameters)
|
for (const auto ¶m : parameters)
|
||||||
{
|
{
|
||||||
|
static constexpr array replace_in_uri
|
||||||
|
{
|
||||||
|
"id", "nickname", "nickname_or_id",
|
||||||
|
"hashtag", "permission_group"
|
||||||
|
};
|
||||||
|
if (any_of(replace_in_uri.begin(), replace_in_uri.end(),
|
||||||
|
[¶m](const auto &s) { return s == param.first; }))
|
||||||
|
{
|
||||||
|
const auto pos{uri.find('<')};
|
||||||
|
if (pos != string::npos)
|
||||||
|
{
|
||||||
|
uri.replace(pos, param.first.size() + 2,
|
||||||
|
get<string>(param.second));
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
static bool first{true};
|
static bool first{true};
|
||||||
if (first)
|
if (first)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue
Block a user