Orbit Framework 2.0.0
A high-performance asynchronous C++20 HTTP server framework.
Loading...
Searching...
No Matches
orbit::middleware::StaticFilesOptions Struct Reference

Options for static_files(). More...

#include <StaticFiles.hpp>

Public Attributes

std::string index = "index.html"
 File served for a request that names a directory; empty disables it.
 
bool serve_dotfiles = false
 Serve files and directories whose name starts with '.' (.env, .git/).
 
std::chrono::seconds max_age {0}
 
std::string mount
 
bool fallthrough = true
 
bool precompressed = false
 

Detailed Description

Options for static_files().

Member Data Documentation

◆ fallthrough

bool orbit::middleware::StaticFilesOptions::fallthrough = true

When no file matches, continue to the next middleware and the routes (true), or answer 404 here (false), which suits a mounted directory whose prefix no route shares.

◆ index

std::string orbit::middleware::StaticFilesOptions::index = "index.html"

File served for a request that names a directory; empty disables it.

◆ max_age

std::chrono::seconds orbit::middleware::StaticFilesOptions::max_age {0}

Cache-Control max-age. Zero sends "no-cache": browsers revalidate with the ETag / Last-Modified on every use.

◆ mount

std::string orbit::middleware::StaticFilesOptions::mount

URL prefix to serve the directory under, e.g. "/files": only requests below it are considered, and the prefix is stripped before the path is resolved (/files/a.png -> <directory>/a.png). Empty serves the directory at the site root.

◆ precompressed

bool orbit::middleware::StaticFilesOptions::precompressed = false

Serve a precompressed sibling when the client accepts its coding: app.js.br, app.js.zst or app.js.gz for app.js, with Content-Encoding, the original's Content-Type and Vary: Accept-Encoding. The plain file is served otherwise, and must exist.

◆ serve_dotfiles

bool orbit::middleware::StaticFilesOptions::serve_dotfiles = false

Serve files and directories whose name starts with '.' (.env, .git/).


The documentation for this struct was generated from the following file: