|
7 | 7 | #pragma clang diagnostic push |
8 | 8 | #pragma clang diagnostic ignored "-Wdeprecated-declarations" |
9 | 9 | #include <fmt/chrono.h> |
10 | | -#pragma clang diagnostic pop |
| 10 | +#pragma clang diagnostic pop |
11 | 11 |
|
12 | 12 | #include <boost/uuid/uuid.hpp> |
13 | 13 | #include <boost/uuid/uuid_generators.hpp> |
|
20 | 20 | #include "irods/private/s3_api/session.hpp" |
21 | 21 | #include "irods/private/s3_api/common.hpp" |
22 | 22 |
|
23 | | -namespace irods::s3::api::common_routines { |
| 23 | +namespace irods::s3::api::common_routines |
| 24 | +{ |
24 | 25 |
|
25 | | - inline std::string convert_time_t_to_str(const time_t& t, const std::string_view format) { |
26 | | - return fmt::format(fmt::runtime(format), fmt::localtime(t)); |
27 | | - } |
| 26 | + inline std::string convert_time_t_to_str(const time_t& t, const std::string_view format) |
| 27 | + { |
| 28 | + return fmt::format(fmt::runtime(format), fmt::localtime(t)); |
| 29 | + } |
28 | 30 |
|
29 | | - inline void send_error_response( |
30 | | - irods::http::session_pointer_type session_ptr, |
31 | | - const boost::beast::http::status status_code, |
32 | | - const std::string& s3_error_code, |
33 | | - const std::string& message, |
34 | | - const std::string& s3_path, |
35 | | - const std::string& func) |
36 | | - { |
37 | | - boost::beast::http::response<boost::beast::http::string_body> response; |
| 31 | + inline void send_error_response( |
| 32 | + irods::http::session_pointer_type session_ptr, |
| 33 | + const boost::beast::http::status status_code, |
| 34 | + const std::string& s3_error_code, |
| 35 | + const std::string& message, |
| 36 | + const std::string& s3_path, |
| 37 | + const std::string& func) |
| 38 | + { |
| 39 | + boost::beast::http::response<boost::beast::http::string_body> response; |
38 | 40 |
|
39 | | - std::string request_id = boost::lexical_cast<std::string>(boost::uuids::random_generator()()); |
40 | | - irods::http::logging::error("{}: {} - {}", func, request_id, message); |
41 | | - response.result(status_code); |
42 | | - response.set(boost::beast::http::field::content_type, "text/xml"); |
| 41 | + std::string request_id = boost::lexical_cast<std::string>(boost::uuids::random_generator()()); |
| 42 | + irods::http::logging::error("{}: {} - {}", func, request_id, message); |
| 43 | + response.result(status_code); |
| 44 | + response.set(boost::beast::http::field::content_type, "text/xml"); |
43 | 45 |
|
44 | | - // build xml response |
45 | | - boost::property_tree::ptree document; |
46 | | - document.add("Error", ""); |
47 | | - document.add("Error.Code", s3_error_code.c_str()); |
48 | | - document.add("Error.Message", message.c_str()); |
49 | | - document.add("Error.Resource", s3_path.c_str()); |
50 | | - document.add("Error.RequestId", request_id.c_str()); |
| 46 | + // build xml response |
| 47 | + boost::property_tree::ptree document; |
| 48 | + document.add("Error", ""); |
| 49 | + document.add("Error.Code", s3_error_code.c_str()); |
| 50 | + document.add("Error.Message", message.c_str()); |
| 51 | + document.add("Error.Resource", s3_path.c_str()); |
| 52 | + document.add("Error.RequestId", request_id.c_str()); |
51 | 53 |
|
52 | | - // add the xml to the response object |
53 | | - std::stringstream s; |
54 | | - boost::property_tree::xml_parser::xml_writer_settings<std::string> settings; |
55 | | - settings.indent_char = ' '; |
56 | | - settings.indent_count = 4; |
57 | | - boost::property_tree::write_xml(s, document, settings); |
58 | | - response.body() = s.str(); |
| 54 | + // add the xml to the response object |
| 55 | + std::stringstream s; |
| 56 | + boost::property_tree::xml_parser::xml_writer_settings<std::string> settings; |
| 57 | + settings.indent_char = ' '; |
| 58 | + settings.indent_count = 4; |
| 59 | + boost::property_tree::write_xml(s, document, settings); |
| 60 | + response.body() = s.str(); |
59 | 61 |
|
60 | | - response.prepare_payload(); |
| 62 | + response.prepare_payload(); |
61 | 63 |
|
62 | | - // log and send the response |
63 | | - irods::http::logging::debug("{}: {} - returned {}", func, request_id, response.reason()); |
64 | | - irods::http::logging::debug("{}: {} - response xml\n{}", func, request_id, response.body()); |
65 | | - session_ptr->send(std::move(response)); |
66 | | - return; |
67 | | - } |
68 | | -} |
| 64 | + // log and send the response |
| 65 | + irods::http::logging::debug("{}: {} - returned {}", func, request_id, response.reason()); |
| 66 | + irods::http::logging::debug("{}: {} - response xml\n{}", func, request_id, response.body()); |
| 67 | + session_ptr->send(std::move(response)); |
| 68 | + return; |
| 69 | + } |
| 70 | +} //namespace irods::s3::api::common_routines |
69 | 71 |
|
70 | 72 | #endif // IRODS_S3_API_COMMON_ROUTINES_HPP |
0 commit comments