Skip to main content

Module server

Module server 

Source
Expand description

High-level server helper for custom Rust servers using webui-router.

This module provides serve_request which encapsulates:

  • Route parameter extraction from the URL
  • HTML SSR rendering via WebUIHandler
  • JSON partial responses for client-side navigation
  • Template inventory management

§Example

ⓘ
use webui::server::{serve_request, ServeRequest, ServeResponse};

let request = ServeRequest {
    path: "/email/thread-5",
    accept_json: false,
    inventory_hex: "",
};

match serve_request(&protocol, &handler, &state, "index.html", &request) {
    Ok(ServeResponse::Html(html)) => { /* serve HTML */ }
    Ok(ServeResponse::Json(json)) => { /* serve JSON */ }
    Err(e) => { /* handle error */ }
}

Structs§

ServeRequest
A server request to be handled by serve_request.

Enums§

ServeResponse
The response from serve_request.

Functions§

serve_request
Handle a server request with automatic route handling.