I have a method that ultimately will take a value from an internal api call
auto val = api->post(req); //step 1
// the post returns a class of "type json"
json api::post(const request& request) { //step 2
// do some job
json j = << some json data>>
return j;
}
Now there is a third step that prepares the http response back to the external caller.
response server::http_response(const json &final_jsond) {
auto response = response{final_json}; //that makes the json a string for the http payload
response.set_header("Content-Type", "application/json");
return response;
}
Now, this code works, however I am wondering if I am missing some modern C++ principles in order to avoid copying the json object from one call to another
Can the above code be optimized by using modern c++ methods to become faster?
returning by reference maybe?