introduce string_view
This commit is contained in:
@@ -16,7 +16,7 @@ Json::Value StringToJson(const std::string& str) {
|
||||
Json::Value json;
|
||||
|
||||
Json::CharReaderBuilder builder;
|
||||
std::stringstream stream(str);
|
||||
std::istringstream stream{ str };
|
||||
std::string errs;
|
||||
if (!Json::parseFromStream(builder, stream, &json, &errs)) {
|
||||
std::cerr << errs << std::endl;
|
||||
|
||||
@@ -16,7 +16,7 @@ Json::Value StringToJson(const std::string& str) {
|
||||
Json::Value json;
|
||||
|
||||
Json::CharReaderBuilder builder;
|
||||
std::stringstream stream(str);
|
||||
std::istringstream stream{ str };
|
||||
std::string errs;
|
||||
if (!Json::parseFromStream(builder, stream, &json, &errs)) {
|
||||
std::cerr << errs << std::endl;
|
||||
|
||||
@@ -39,11 +39,11 @@ int main(int argc, char* argv[]) {
|
||||
std::make_shared<BookListView>(),
|
||||
{ "GET", "POST" });
|
||||
|
||||
server.Route(webcc::R("/books/(\\d+)"),
|
||||
server.Route(webcc::R{ "/books/(\\d+)" },
|
||||
std::make_shared<BookDetailView>(photo_dir),
|
||||
{ "GET", "PUT", "DELETE" });
|
||||
|
||||
server.Route(webcc::R("/books/(\\d+)/photo"),
|
||||
server.Route(webcc::R{ "/books/(\\d+)/photo" },
|
||||
std::make_shared<BookPhotoView>(photo_dir),
|
||||
{ "GET", "PUT", "DELETE" });
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ int main(int argc, char* argv[]) {
|
||||
std::cout << " $ ./form_client path/to/webcc/data/upload" << std::endl;
|
||||
std::cout << " $ ./form_client path/to/webcc/data/upload "
|
||||
<< "http://httpbin.org/post" << std::endl;
|
||||
std::cout << "(Post the example 'form_server')" << std::endl;
|
||||
std::cout << "(Post to the example 'form_server')" << std::endl;
|
||||
std::cout << " $ ./form_client path/to/webcc/data/upload "
|
||||
"http://localhost:8080/upload"
|
||||
<< std::endl;
|
||||
@@ -43,8 +43,7 @@ int main(int argc, char* argv[]) {
|
||||
webcc::ClientSession session;
|
||||
|
||||
try {
|
||||
auto r = session.Send(webcc::RequestBuilder{}
|
||||
.Post(url)
|
||||
auto r = session.Send(WEBCC_POST(url)
|
||||
.FormFile("file", upload_dir / "remember.txt")
|
||||
.FormData("json", "{}", "application/json")());
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ Json::Value StringToJson(const std::string& str) {
|
||||
Json::Value json;
|
||||
|
||||
Json::CharReaderBuilder builder;
|
||||
std::stringstream stream(str);
|
||||
std::istringstream stream{ str };
|
||||
std::string errors;
|
||||
if (!Json::parseFromStream(builder, stream, &json, &errors)) {
|
||||
std::cerr << errors << std::endl;
|
||||
|
||||
Reference in New Issue
Block a user