mirror of
https://github.com/CrowCpp/Crow.git
synced 2024-06-07 21:10:44 +00:00
Merge branch 'master' into middleware_reorganizing
This commit is contained in:
commit
7c88cdbb60
@ -1,3 +1,5 @@
|
||||
//#define CROW_STATIC_DRIECTORY "alternative_directory/"
|
||||
//#define CROW_STATIC_ENDPOINT "/alternative_endpoint/<path>"
|
||||
#include "crow.h"
|
||||
|
||||
int main()
|
||||
@ -20,3 +22,8 @@ CROW_ROUTE(app, "/")
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/// You can also use the `/static` directory and endpoint (the directory needs to have the same path as your executable).
|
||||
/// Any file inside the static directory will have the same path it would in your filesystem.
|
||||
|
||||
/// TO change the static directory or endpoint, use the macros above (replace `alternative_directory` and/or `alternative_endpoint` with your own)
|
||||
|
@ -161,7 +161,16 @@ namespace crow
|
||||
///Run the server
|
||||
void run()
|
||||
{
|
||||
#ifndef CROW_DISABLE_STATIC_DIR
|
||||
route<crow::black_magic::get_parameter_tag(CROW_STATIC_ENDPOINT)>(CROW_STATIC_ENDPOINT)
|
||||
([](const crow::request&, crow::response& res, std::string file_path_partial)
|
||||
{
|
||||
res.set_static_file_info(CROW_STATIC_DIRECTORY + file_path_partial);
|
||||
res.end();
|
||||
});
|
||||
validate();
|
||||
#endif
|
||||
|
||||
#ifdef CROW_ENABLE_SSL
|
||||
if (use_ssl_)
|
||||
{
|
||||
|
@ -25,6 +25,13 @@
|
||||
#define CROW_LOG_LEVEL 1
|
||||
#endif
|
||||
|
||||
#ifndef CROW_STATIC_DIRECTORY
|
||||
#define CROW_STATIC_DIRECTORY "static/"
|
||||
#endif
|
||||
#ifndef CROW_STATIC_ENDPOINT
|
||||
#define CROW_STATIC_ENDPOINT "/static/<path>"
|
||||
#endif
|
||||
|
||||
|
||||
// compiler flags
|
||||
#if __cplusplus >= 201402L
|
||||
|
Loading…
Reference in New Issue
Block a user