mirror of
https://github.com/CrowCpp/Crow.git
synced 2024-06-07 21:10:44 +00:00
remove the need for #define CROW_MAIN
.
This is achieved using the conts type qualifier as it gives internal linkage. fixes #273 Signed-off-by: Luca Schlecker <luca.schlecker@hotmail.com>
This commit is contained in:
parent
b1718befaa
commit
5823a5984e
@ -81,12 +81,12 @@ namespace crow
|
||||
|
||||
response(std::string contentType, std::string body) : body(std::move(body))
|
||||
{
|
||||
set_header("Content-Type",mime_types[contentType]);
|
||||
set_header("Content-Type", mime_types.at(contentType));
|
||||
}
|
||||
|
||||
response(int code, std::string contentType, std::string body): code(code),body(std::move(body))
|
||||
{
|
||||
set_header("Content-Type",mime_types[contentType]);
|
||||
set_header("Content-Type", mime_types.at(contentType));
|
||||
}
|
||||
|
||||
response& operator = (const response& r) = delete;
|
||||
@ -221,7 +221,7 @@ namespace crow
|
||||
this->add_header("Content-length", std::to_string(file_info.statbuf.st_size));
|
||||
|
||||
if (extension != ""){
|
||||
mimeType = mime_types[extension];
|
||||
mimeType = mime_types.at(extension);
|
||||
if (mimeType != "")
|
||||
this-> add_header("Content-Type", mimeType);
|
||||
else
|
||||
|
@ -3,9 +3,7 @@
|
||||
#include <string>
|
||||
|
||||
namespace crow {
|
||||
|
||||
#ifdef CROW_MAIN
|
||||
std::unordered_map<std::string, std::string> mime_types {
|
||||
const std::unordered_map<std::string, std::string> mime_types {
|
||||
{"shtml", "text/html"},
|
||||
{"htm", "text/html"},
|
||||
{"html", "text/html"},
|
||||
@ -115,7 +113,4 @@ namespace crow {
|
||||
{"wmv", "video/x-ms-wmv"},
|
||||
{"avi", "video/x-msvideo"}
|
||||
};
|
||||
#else
|
||||
extern std::unordered_map<std::string, std::string> mime_types;
|
||||
#endif
|
||||
}
|
||||
|
@ -19,11 +19,8 @@
|
||||
namespace crow
|
||||
{
|
||||
|
||||
#ifdef CROW_MAIN
|
||||
uint16_t INVALID_BP_ID{0xFFFF};
|
||||
#else
|
||||
extern uint16_t INVALID_BP_ID;
|
||||
#endif
|
||||
constexpr const uint16_t INVALID_BP_ID{0xFFFF};
|
||||
|
||||
/// A base class for all rules.
|
||||
|
||||
/// Used to provide a common interface for code dealing with different types of rules.
|
||||
|
@ -1,10 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
namespace crow {
|
||||
|
||||
#ifdef CROW_MAIN
|
||||
char VERSION[] = "master";
|
||||
#else
|
||||
extern char VERSION[];
|
||||
#endif
|
||||
constexpr const char VERSION[] = "master";
|
||||
}
|
||||
|
@ -20,9 +20,7 @@ def main():
|
||||
"#include <string>",
|
||||
"",
|
||||
"namespace crow {",
|
||||
"",
|
||||
"#ifdef CROW_MAIN"
|
||||
tabspace + "std::unordered_map<std::string, std::string> mime_types {"])
|
||||
tabspace + "const std::unordered_map<std::string, std::string> mime_types {"])
|
||||
|
||||
with open(file_path, "r") as mtfile:
|
||||
incomplete = ""
|
||||
@ -44,9 +42,6 @@ def main():
|
||||
outLines[-1] = outLines[-1][:-1]
|
||||
outLines.extend([
|
||||
tabspace + "};",
|
||||
"#else",
|
||||
"extern std::unordered_map<std::string, std::string> mime_types;",
|
||||
"#endif",
|
||||
"}"
|
||||
])
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user