EWSLite Web Server API

The EWSLite library (located in the target/mcoewslite directory) is a compact embedded HTTP server written in C. It is designed for building RESTful APIs in resource-constrained environments and provides basic support for HTTP methods, request routing, JSON response generation, and WebSocket communication. Configuration is performed at compile time through macro definitions, which allows functionality to be precisely tailored to the needs of a specific application while keeping overhead minimal.

Within eXtremeDB/rt, EWSLite is used to implement the monitoring module, located in the target/mcorestrt directory. This module exposes internal database runtime statistics through a REST API, enabling applications to query metrics such as memory usage, transaction activity, I/O operation counts, and other performance indicators. Responses are generated in structured JSON format, making them easy to consume by external monitoring tools, dashboards, or custom applications. By relying on EWSLite, the monitoring module delivers real-time visibility into database operations with minimal overhead, while remaining fully portable across platforms supported by eXtremeDB/rt.

API Function Index

Macros and Structures

Macros and structures
Macros and structures used in the EWSLite API.
lews_connection_context_t
Description of the connection context structure.
mco_lews_handle_func_h
Description of HTTP request handler function type.

HTTP Server Lifecycle Management

mco_lews_initialize
Initializes the EWSLite HTTP server with the specified parameters.
mco_lews_destroy
Closes EWSLite HTTP server sockets and releases associated resources.
mco_lews_start
Starts the EWSLite HTTP server listening loop.
mco_lews_stop
Sends a stop signal to the EWSLite HTTP server.
mco_lews_has_been_stopped
Checks whether the EWSLite HTTP server has been stopped.
mco_lews_start_listen
Starts listening for incoming HTTP connections.
mco_lews_check_connections
Checks for new incoming HTTP connections and handles them.

Request/Response Buffer I/O

mco_lews_append_header_end
Appends the end-of-headers marker to the response buffer.
mco_lews_append_http_header
Appends an HTTP header to the response buffer.
mco_lews_append_int
Appends an integer value to the response buffer.
mco_lews_append_str
Appends a string to the response buffer.
mco_lews_append_uint64
Appends a 64-bit unsigned integer to the response buffer.
mco_lews_flush
Flushes the response buffer.
mco_lews_send_response_err
Sends a standard HTTP error response to the client.
mco_lews_startswith
Checks whether the buffer contents start with a given null-terminated string.
mco_lews_startswith_ci
Checks whether the buffer contents start with a given null-terminated string (case-insensitive).
mco_lews_strcmp
Compares a null-terminated string against the buffer contents.
mco_lews_strcmp_ci
Compares a null-terminated string against the buffer contents (case-insensitive).
mco_lews_get_header_value
Retrieves the value of a specified HTTP header from the request.
mco_lews_get_query_param_str
Retrieves the value of a specified query parameter from the request buffer.
mco_lews_get_query_param_int
Retrieves the integer value of a specified query parameter from the request buffer.
mco_lews_base64_encode
Encodes binary data in Base64.
mco_lews_url_param_decode
Decodes a URL-encoded string.
IS_METHOD
Checks whether the current request method matches a specified method.
IS_URL
Checks whether the current request URL matches a specified URL.

WebSocket Protocol Handling

mco_lews_is_websocket_request
Checks whether the current request is a WebSocket upgrade request.
mco_lews_websocket_negotiation_response
Generates a WebSocket handshake response.
mco_lews_is_websocket_close_frame
Checks whether the current frame is a WebSocket close frame.
mco_lews_send_websocket_closing_frame
Sends a WebSocket closing frame to the client.
mco_lews_send_websocket_data_frame
Sends a WebSocket data frame to the client.

JSON Response Serialization

mco_lJSON_ctx_open
Initializes a JSON serialization context.
mco_lJSON_ctx_close
Finalizes a JSON serialization context.
mco_lJSON_arr_open
Opens a JSON array in the serialization context.
mco_lJSON_obj_open
Opens a JSON object in the serialization context.
mco_lJSON_obj_open_obj
Opens a nested JSON object within a JSON object.
mco_lJSON_obj_open_arr
Opens a JSON array within a JSON object.
mco_lJSON_obj_close
Closes a JSON object or array in the serialization context.
mco_lJSON_arr_add_int
Adds an integer value to a JSON array.
mco_lJSON_arr_add_str
Adds a string value to a JSON array.
mco_lJSON_arr_add_uint
Adds an unsigned 64-bit integer value to a JSON array.
mco_lJSON_obj_add_int
Adds an integer value to a JSON object.
mco_lJSON_obj_add_str
Adds a string value to a JSON object.
mco_lJSON_obj_add_uint
Adds an unsigned 64-bit integer value to a JSON object.