Make _endpoint_map static.
This commit is contained in:
parent
fba5a576f0
commit
159cd05f5a
|
@ -302,7 +302,7 @@ public:
|
||||||
*
|
*
|
||||||
* @since 0.1.0
|
* @since 0.1.0
|
||||||
*/
|
*/
|
||||||
explicit API();
|
explicit API(const endpoint_type &endpoint);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief Convert #endpoint_type to `std::string_view`.
|
* @brief Convert #endpoint_type to `std::string_view`.
|
||||||
|
@ -310,14 +310,14 @@ public:
|
||||||
* @since 0.1.0
|
* @since 0.1.0
|
||||||
*/
|
*/
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
inline string_view endpoint_to_string_view(const endpoint_type &endpoint)
|
inline string_view to_string_view() const
|
||||||
const
|
|
||||||
{
|
{
|
||||||
return _endpoint_map.at(endpoint).data();
|
return _endpoint_map.at(_endpoint).data();
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const map<endpoint_type,string_view> _endpoint_map;
|
const endpoint_type _endpoint;
|
||||||
|
static const map<endpoint_type,string_view> _endpoint_map;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace mastodonpp
|
} // namespace mastodonpp
|
||||||
|
|
|
@ -74,7 +74,6 @@ public:
|
||||||
private:
|
private:
|
||||||
Instance &_instance;
|
Instance &_instance;
|
||||||
const string_view _baseuri;
|
const string_view _baseuri;
|
||||||
const API _api;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace mastodonpp
|
} // namespace mastodonpp
|
||||||
|
|
10
src/api.cpp
10
src/api.cpp
|
@ -19,8 +19,11 @@
|
||||||
namespace mastodonpp
|
namespace mastodonpp
|
||||||
{
|
{
|
||||||
|
|
||||||
API::API()
|
API::API(const endpoint_type &endpoint)
|
||||||
: _endpoint_map
|
: _endpoint{endpoint}
|
||||||
|
{}
|
||||||
|
|
||||||
|
const map<API::endpoint_type,string_view> API::_endpoint_map
|
||||||
{
|
{
|
||||||
{v1::apps, "/api/v1/apps"},
|
{v1::apps, "/api/v1/apps"},
|
||||||
{v1::apps_verify_credentials, "/api/v1/apps/verify/credentials"},
|
{v1::apps_verify_credentials, "/api/v1/apps/verify/credentials"},
|
||||||
|
@ -238,7 +241,6 @@ API::API()
|
||||||
"/api/pleroma/pleroma/notification_settings"},
|
"/api/pleroma/pleroma/notification_settings"},
|
||||||
{pleroma::pleroma_healthcheck, "/api/pleroma/pleroma/healthcheck"},
|
{pleroma::pleroma_healthcheck, "/api/pleroma/pleroma/healthcheck"},
|
||||||
{pleroma::pleroma_change_email, "/api/pleroma/pleroma/change_email"},
|
{pleroma::pleroma_change_email, "/api/pleroma/pleroma/change_email"},
|
||||||
}
|
};
|
||||||
{}
|
|
||||||
|
|
||||||
} // namespace mastodonpp
|
} // namespace mastodonpp
|
||||||
|
|
|
@ -22,14 +22,13 @@ namespace mastodonpp
|
||||||
Connection::Connection(Instance &instance)
|
Connection::Connection(Instance &instance)
|
||||||
: _instance{instance}
|
: _instance{instance}
|
||||||
, _baseuri{instance.get_baseuri()}
|
, _baseuri{instance.get_baseuri()}
|
||||||
, _api{}
|
|
||||||
{}
|
{}
|
||||||
|
|
||||||
answer_type Connection::get(const API::endpoint_type &endpoint)
|
answer_type Connection::get(const API::endpoint_type &endpoint)
|
||||||
{
|
{
|
||||||
return make_request(
|
return make_request(
|
||||||
http_method::GET,
|
http_method::GET,
|
||||||
string(_baseuri).append(_api.endpoint_to_string_view(endpoint)));
|
string(_baseuri).append(API{endpoint}.to_string_view()));
|
||||||
}
|
}
|
||||||
|
|
||||||
answer_type Connection::get(const string_view &endpoint)
|
answer_type Connection::get(const string_view &endpoint)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user