Fix the ambiguity of the contructors of FormPart.

This commit is contained in:
Adam Gu
2019-07-14 09:01:48 +08:00
parent 381b148806
commit 2a20030f7e
4 changed files with 43 additions and 31 deletions
+12 -11
View File
@@ -135,26 +135,29 @@ private:
// -----------------------------------------------------------------------------
class FormPart;
using FormPartPtr = std::shared_ptr<FormPart>;
// A part of the multipart form data.
class FormPart {
public:
FormPart() = default;
// Construct a file part.
// The file name will be extracted from path.
// The media type, if not provided, will be inferred from file extension.
FormPart(const std::string& name, const Path& path,
const std::string& media_type = "");
FormPart(const FormPart&) = delete;
FormPart& operator=(const FormPart&) = delete;
// Construct a non-file part.
// The data will be moved, no file name is needed.
// The media type is optional. If the data is a JSON string, you can specify
// media type as "application/json".
FormPart(const std::string& name, std::string&& data,
const std::string& media_type = "");
static FormPartPtr New(const std::string& name, std::string&& data,
const std::string& media_type = "");
FormPart(const FormPart&) = delete;
FormPart& operator=(const FormPart&) = delete;
// Construct a file part.
// The file name will be extracted from path.
// The media type, if not provided, will be inferred from file extension.
static FormPartPtr NewFile(const std::string& name, const Path& path,
const std::string& media_type = "");
// API: SERVER
const std::string& name() const {
@@ -243,8 +246,6 @@ private:
std::string data_;
};
using FormPartPtr = std::shared_ptr<FormPart>;
} // namespace webcc
#endif // WEBCC_COMMON_H_