111 std::shared_ptr<class http_plugin_impl> my;
144 for(
auto itr = exc.
get_log().begin(); itr != exc.
get_log().end(); ++itr ) {
146 if(
details.size() >= limit )
break;
149 include_full_log ? itr->get_message() : itr->get_limited_message(),
150 itr->get_context().get_file(),
151 itr->get_context().get_line_number(),
152 itr->get_context().get_method()
171 size_t right = body.size() - 1;
175 if (body[left] ==
' ') {
183 if (body[right] ==
' ') {
189 if ((left == right) && (body[left] ==
' ')) {
192 return std::string_view(body).substr(left, right-left+1);
197 if (trimmed_body_view.empty()) {
200 const size_t body_size = trimmed_body_view.size();
201 if ((body_size > 1) && (trimmed_body_view.at(0) ==
'{') && (trimmed_body_view.at(body_size - 1) ==
'}')) {
202 for(
size_t idx=1; idx<body_size-1; ++idx)
204 if ((trimmed_body_view.at(idx) !=
' ') && (trimmed_body_view.at(idx) !=
'\t'))
221 template<
typename T, http_params_types params_type>
225 SYS_THROW(chain::invalid_http_request,
"A Request body is required");
233 if constexpr (std::is_same_v<T, std::string>) {
234 return std::string(
"{}");
239 SYS_THROW(chain::invalid_http_request,
"no parameter should be given");
243 }
catch (
const chain::chain_exception& e) {
#define SYS_THROW(exc_type, FORMAT,...)
#define SYS_RETHROW_EXCEPTIONS(exception_type, FORMAT,...)
Used to generate a useful error report when an exception is thrown.
const log_messages & get_log() const
const char * name() const
const char * what() const noexcept override
static variant from_string(const string &utf8_str, const parse_type ptype=parse_type::legacy_parser, uint32_t max_depth=DEFAULT_MAX_RECURSION_DEPTH)
stores null, int64, uint64, double, bool, string, std::vector<variant>, and variant_object's.
void add_api(const api_description &api, int priority=appbase::priority::medium_low)
void add_handler(const string &url, const url_handler &, int priority=appbase::priority::medium_low)
void add_async_handler(const string &url, const url_handler &handler)
virtual void set_program_options(options_description &, options_description &cfg) override
bool verbose_errors() const
get_supported_apis_result get_supported_apis() const
fc::microseconds get_max_response_time() const
bool is_on_loopback() const
static void set_defaults(const http_plugin_defaults config)
void plugin_initialize(const variables_map &options)
static void handle_exception(const char *api_name, const char *call_name, const string &body, url_response_callback cb)
void add_async_api(const api_description &api)
void handle_sighup() override
Defines exception's used by fc.
bool is_empty_content(const std::string &body)
std::map< string, url_handler > api_description
An API, containing URLs and handlers.
std::function< void(string, string, url_response_callback)> url_handler
Callback type for a URL handler.
std::string_view make_trimmed_string_view(const std::string &body)
Used to trim whitespace from body. Returned string_view valid only for lifetime of body.
std::function< void(int, fc::variant)> url_response_callback
A callback function provided to a URL handler to allow it to specify the HTTP response code and body.
T parse_params(const std::string &body)
#define APPBASE_PLUGIN_REQUIRES(PLUGINS)
#define T(meth, val, expected)
fc::variant call(const std::string &url, const std::string &path, const T &v)
#define FC_REFLECT(TYPE, MEMBERS)
Specializes fc::reflector for TYPE.
unsigned __int64 uint64_t
static constexpr int medium_low
Immutable except for fc::from_variant.
vector< error_detail > details
error_info(const fc::exception &exc, bool include_full_log)
static const uint8_t details_limit
Structure used to create JSON error responses.
string default_unix_socket_path
uint16_t default_http_port