REDAC HybridController
Firmware for LUCIDAC/REDAC Teensy
Loading...
Searching...
No Matches
server.cpp File Reference
#include <web/server.h>
#include <net/auth.h>
#include <net/ethernet.h>
#include <protocol/protocol.h>
#include <utils/logging.h>
#include <web/assets.h>
#include <web/websockets.h>
#include <build/distributor.h>
#include <build/distributor_generated.h>
#include "web/aWOT.h"
Include dependency graph for server.cpp:

Go to the source code of this file.

Classes

struct  HTTPContext
 

Namespaces

namespace  web
 

Macros

#define ENABLE_AWOT_NAMESPACE
 
#define SERVER_VERSION   "LucidacWebServer/" FIRMWARE_VERSION
 
#define ERR(msg)
 

Functions

bool contains (const char *haystack, const char *needle)
 
bool equals (const char *a, const char *b)
 
FLASHMEM void allocate_interesting_headers (awot::Application &app)
 aWOT preallocates everything, therefore request headers are not dynamically parsed but instead only seved when previously storage was allocated.
 
FLASHMEM void notfound (awot::Request &req, awot::Response &res)
 
FLASHMEM void serve_static (const web::StaticFile &file, awot::Response &res)
 
FLASHMEM void serve_static (awot::Request &req, awot::Response &res)
 
FLASHMEM void index (awot::Request &req, awot::Response &res)
 
FLASHMEM void web::convertToJson (const StaticFile &file, JsonVariant serialized)
 
FLASHMEM void about_static (awot::Request &req, awot::Response &res)
 
FLASHMEM void set_cors (awot::Request &req, awot::Response &res)
 
FLASHMEM void api_preflight (awot::Request &req, awot::Response &res)
 
FLASHMEM void api (awot::Request &req, awot::Response &res)
 
FLASHMEM void websocket_upgrade (awot::Request &req, awot::Response &res)
 
FLASHMEM void onWebsocketMessageCallback (websockets::WebsocketsClient &wsclient, websockets::WebsocketsMessage msg)
 

Variables

awot::Application webapp
 

Macro Definition Documentation

◆ ENABLE_AWOT_NAMESPACE

#define ENABLE_AWOT_NAMESPACE

Definition at line 17 of file server.cpp.

◆ ERR

#define ERR ( msg)
Value:
{ \
if (!has_errors) { \
has_errors = true; \
res.status(400); \
res.set("Content-Type", "text/plain"); \
res.println("This URL is only for Websocket Upgrade."); \
} \
res.println("Error: " msg); \
}

Definition at line 217 of file server.cpp.

Referenced by websocket_upgrade().

◆ SERVER_VERSION

#define SERVER_VERSION   "LucidacWebServer/" FIRMWARE_VERSION

Definition at line 27 of file server.cpp.

Referenced by about_static(), index(), notfound(), set_cors(), and websocket_upgrade().

Function Documentation

◆ about_static()

FLASHMEM void about_static ( awot::Request & req,
awot::Response & res )

Definition at line 153 of file server.cpp.

References SERVER_VERSION.

◆ allocate_interesting_headers()

FLASHMEM void allocate_interesting_headers ( awot::Application & app)

aWOT preallocates everything, therefore request headers are not dynamically parsed but instead only seved when previously storage was allocated.

Therefore this function serves as a global registry for interesting client-side headers.

Definition at line 44 of file server.cpp.

◆ api()

FLASHMEM void api ( awot::Request & req,
awot::Response & res )

Definition at line 193 of file server.cpp.

References set_cors().

◆ api_preflight()

FLASHMEM void api_preflight ( awot::Request & req,
awot::Response & res )

Definition at line 188 of file server.cpp.

References set_cors().

◆ contains()

bool contains ( const char * haystack,
const char * needle )

Definition at line 21 of file server.cpp.

Referenced by websocket_upgrade().

◆ equals()

bool equals ( const char * a,
const char * b )

Definition at line 23 of file server.cpp.

Referenced by websocket_upgrade().

◆ index()

FLASHMEM void index ( awot::Request & req,
awot::Response & res )

Definition at line 120 of file server.cpp.

References serve_static(), and SERVER_VERSION.

◆ notfound()

FLASHMEM void notfound ( awot::Request & req,
awot::Response & res )

Definition at line 65 of file server.cpp.

References SERVER_VERSION.

Referenced by serve_static().

◆ onWebsocketMessageCallback()

FLASHMEM void onWebsocketMessageCallback ( websockets::WebsocketsClient & wsclient,
websockets::WebsocketsMessage msg )

Definition at line 326 of file server.cpp.

◆ serve_static() [1/2]

FLASHMEM void serve_static ( awot::Request & req,
awot::Response & res )

Definition at line 100 of file server.cpp.

References notfound(), and serve_static().

◆ serve_static() [2/2]

FLASHMEM void serve_static ( const web::StaticFile & file,
awot::Response & res )

Definition at line 75 of file server.cpp.

References uint32_t.

Referenced by index(), and serve_static().

◆ set_cors()

FLASHMEM void set_cors ( awot::Request & req,
awot::Response & res )

Definition at line 177 of file server.cpp.

References SERVER_VERSION.

Referenced by api(), and api_preflight().

◆ websocket_upgrade()

FLASHMEM void websocket_upgrade ( awot::Request & req,
awot::Response & res )

Definition at line 228 of file server.cpp.

References contains(), equals(), ERR, and SERVER_VERSION.

Variable Documentation

◆ webapp

awot::Application webapp

Definition at line 37 of file server.cpp.