Boost C++ Libraries

PrevUpHomeNext

Struct json_body_arg

boost::taar::handler::json_body_arg — Argument provider that parses the request body as a JSON value.

Synopsis

// In header: <boost/taar/handler/rest_arg.hpp>


struct json_body_arg {

  // public member functions
  template<typename... T> json_body_arg(T &&...);
  json_body_arg(all_content_types_t, description = {});
  std::string name() const;
  std::string const & description() const;
  std::unordered_set< std::string > const & content_types() const;
  taar::result< boost::json::value > 
  operator()(boost::beast::http::request< boost::beast::http::string_body > const &, 
             matcher::context const &) const;

  // public data members
  std::unordered_set< std::string > content_types_;
  std::string description_;
};

Description

By default only requests with Content-Type: application/json are accepted; pass extra content types to the constructor or all_content_types to widen the set. Malformed JSON is reported as error::invalid_request_format.

json_body_arg public member functions

  1. template<typename... T> json_body_arg(T &&... args);
  2. json_body_arg(all_content_types_t, description d = {});
  3. std::string name() const;
  4. std::string const & description() const;
  5. std::unordered_set< std::string > const & content_types() const;
  6. taar::result< boost::json::value > 
    operator()(boost::beast::http::request< boost::beast::http::string_body > const & request, 
               matcher::context const &) const;

PrevUpHomeNext