REDAC HybridController
Firmware for LUCIDAC/REDAC Teensy
Loading...
Searching...
No Matches

Static web server file assets are compiled into the firmware code as binary objects. More...

#include <assets.h>

Collaboration diagram for web::StaticFile:

Classes

struct  HttpHeader
 up to 10 (unstructured) HTTP Headers, for instance Content-Type, Content-Encoding, ETag, etc. More...
 

Public Attributes

const char * filename
 
const uint8_t * start
 begin of content in memory, determined by linker symbol
 
const uint32_t size
 size in bytes; determined by linker symbol
 
struct web::StaticFile::HttpHeader headers [max_headers]
 
const uint32_t lastmod
 C Unix timestamp for cache control.
 

Static Public Attributes

static constexpr int max_headers = 10
 

Detailed Description

Static web server file assets are compiled into the firmware code as binary objects.

For ease of the build system, we use an inline assembler incbin command. This way, the C compiler does not need to preprocess the amount of static data and compilation does not slow down.

See also https://www.devever.net/~hl/incbin and https://dox.ipxe.org/embedded_8c_source.html for where this approach stems from.

The assets.cpp file is compiled by a shell script in the /lib/communication/assets directory. The output of that file is not part of the git repository, since the actual assets are also not part of the firmware git repository.

Instead, a fallback code is put there, to allow compiling without any assets.

Technically, the asset structure works as a array of structures but the API is that of a lookup by filename.

Definition at line 34 of file assets.h.

Member Data Documentation

◆ filename

const char* web::StaticFile::filename

Definition at line 35 of file assets.h.

Referenced by about_static(), web::convertToJson(), and serve_static().

◆ headers

struct web::StaticFile::HttpHeader web::StaticFile::headers[max_headers]

Referenced by serve_static().

◆ lastmod

const uint32_t web::StaticFile::lastmod

C Unix timestamp for cache control.

Definition at line 47 of file assets.h.

Referenced by web::convertToJson().

◆ max_headers

int web::StaticFile::max_headers = 10
staticconstexpr

Definition at line 39 of file assets.h.

Referenced by serve_static().

◆ size

const uint32_t web::StaticFile::size

size in bytes; determined by linker symbol

Definition at line 37 of file assets.h.

Referenced by web::convertToJson(), and serve_static().

◆ start

const uint8_t* web::StaticFile::start

begin of content in memory, determined by linker symbol

Definition at line 36 of file assets.h.

Referenced by web::convertToJson(), and serve_static().


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