forked from boostorg/beast
Group common example headers
This commit is contained in:
1 parent
84d7601bdf
commit
bb1dd72638
27 files changed
+143
-88
No files matched your search
@@ -8,8 +8,9 @@
|
||||
#ifndef BEAST_EXAMPLE_SERVER_FILE_SERVICE_HPP
|
||||
#define BEAST_EXAMPLE_SERVER_FILE_SERVICE_HPP
|
||||
|
||||
#include "file_body.hpp"
|
||||
#include "framework.hpp"
|
||||
#include "../common/file_body.hpp"
|
||||
#include "../common/mime_types.hpp"
|
||||
|
||||
#include <beast/core/string.hpp>
|
||||
#include <beast/http/empty_body.hpp>
|
||||
@@ -182,37 +183,6 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
// Return a reasonable mime type based on the extension of a file.
|
||||
//
|
||||
beast::string_view
|
||||
mime_type(boost::filesystem::path const& path) const
|
||||
{
|
||||
using beast::iequals;
|
||||
auto const ext = path.extension().string();
|
||||
if(iequals(ext, ".txt")) return "text/plain";
|
||||
if(iequals(ext, ".htm")) return "text/html";
|
||||
if(iequals(ext, ".html")) return "text/html";
|
||||
if(iequals(ext, ".php")) return "text/html";
|
||||
if(iequals(ext, ".css")) return "text/css";
|
||||
if(iequals(ext, ".js")) return "application/javascript";
|
||||
if(iequals(ext, ".json")) return "application/json";
|
||||
if(iequals(ext, ".xml")) return "application/xml";
|
||||
if(iequals(ext, ".swf")) return "application/x-shockwave-flash";
|
||||
if(iequals(ext, ".flv")) return "video/x-flv";
|
||||
if(iequals(ext, ".png")) return "image/png";
|
||||
if(iequals(ext, ".jpe")) return "image/jpeg";
|
||||
if(iequals(ext, ".jpeg")) return "image/jpeg";
|
||||
if(iequals(ext, ".jpg")) return "image/jpeg";
|
||||
if(iequals(ext, ".gif")) return "image/gif";
|
||||
if(iequals(ext, ".bmp")) return "image/bmp";
|
||||
if(iequals(ext, ".ico")) return "image/vnd.microsoft.icon";
|
||||
if(iequals(ext, ".tiff")) return "image/tiff";
|
||||
if(iequals(ext, ".tif")) return "image/tiff";
|
||||
if(iequals(ext, ".svg")) return "image/svg+xml";
|
||||
if(iequals(ext, ".svgz")) return "image/svg+xml";
|
||||
return "application/text";
|
||||
}
|
||||
|
||||
// Return an HTTP Not Found response
|
||||
//
|
||||
template<class Body, class Fields>
|
||||
|
||||
Reference in new issue
Block a user