introduce string_view

This commit is contained in:
Chunting Gu
2021-06-17 18:58:53 +08:00
parent 751a3539ae
commit 26bb6b341a
38 changed files with 404 additions and 344 deletions
+5 -9
View File
@@ -61,13 +61,13 @@ public:
return *this;
}
ResponseBuilder& MediaType(const std::string& media_type) {
media_type_ = media_type;
ResponseBuilder& MediaType(string_view media_type) {
media_type_ = ToString(media_type);
return *this;
}
ResponseBuilder& Charset(const std::string& charset) {
charset_ = charset;
ResponseBuilder& Charset(string_view charset) {
charset_ = ToString(charset);
return *this;
}
@@ -98,11 +98,7 @@ public:
ResponseBuilder& File(const fs::path& path, bool infer_media_type = true,
std::size_t chunk_size = 1024);
ResponseBuilder& Header(const std::string& key, const std::string& value) {
headers_.push_back(key);
headers_.push_back(value);
return *this;
}
ResponseBuilder& Header(string_view key, string_view value);
// Add the `Date` header to the response.
ResponseBuilder& Date();