Skip to content

Commit

Permalink
[api] http.Directory to support default index.html page
Browse files Browse the repository at this point in the history
  • Loading branch information
pajama-coder committed Aug 27, 2023
1 parent d3d5aad commit 2bc79c8
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/api/http.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,13 @@ auto Directory::serve(Message *request) -> Message* {
auto i = m_cache.find(path);
if (i == m_cache.end()) {
Data raw, gz, br;
if (!m_loader->load_file(path, raw)) return nullptr;
if (!m_loader->load_file(path, raw)) {
if (path.back() != '/') path += '/';
path += "index.html";
if (!m_loader->load_file(path, raw)) {
return nullptr;
}
}
m_loader->load_file(path + ".gz", gz);
m_loader->load_file(path + ".br", br);

Expand Down

0 comments on commit 2bc79c8

Please sign in to comment.