Device Detection and IP Intelligence for the 51Degrees Pipeline, in Rust

dd-web-client-only-cloud.rs File Reference

Classes

struct  PageState
 What the page handler needs, carried as the router state. More...

Functions

const endpoint unwrap_or (DEFAULT_CLOUD_BASE).trim_end_matches('/')) } pub struct Options
 Options that drive [run].
struct PageState build_app (resource_key:&str, endpoint:Option<&str >) -> Router
 Build the client-only application router.
pub fn run (options:Options) -> anyhow::Result<()>
 Serve the page over TCP until interrupted.
async fn home (State(state):State< PageState >) -> Html< String >
 The home-page handler: a client-only page whose #content region is filled by the cloud resource script and the shared callback.
fn main () -> anyhow::Result<()>
async fn get (app:Router, uri:&str) -> Response
async fn body_string (response:Response) -> String
async fn page_renders_with_resource_script_and_assets ()

Variables

mod web_support
const DEFAULT_CLOUD_BASE
 The public 51Degrees cloud API base the resource script is loaded from when _51DEGREES_CLOUD_ENDPOINT is unset.
resource_key __pad0__
resource_key cloud_base
mod tests

Function Documentation

◆ body_string()

async fn body_string ( response:Response ) -> String

◆ build_app()

struct PageState build_app ( resource_key:& str,
endpoint:Option<&str >  ) -> Router

Build the client-only application router.

The server only serves a static page and the two vendored assets; all detection happens in the browser. The resource key is carried as router state so the page handler can build the resource-script URL, together with the cloud base it is loaded from.

◆ get()

async fn get ( app:Router ,
uri:& str ) -> Response

◆ home()

async fn home ( State(state):State< PageState > ) -> Html< String >

The home-page handler: a client-only page whose #content region is filled by the cloud resource script and the shared callback.

◆ main()

fn main ( ) -> anyhow::Result<()>

◆ page_renders_with_resource_script_and_assets()

async fn page_renders_with_resource_script_and_assets ( )

◆ run()

pub fn run ( options:Options ) -> anyhow::Result<()>

Serve the page over TCP until interrupted.

◆ unwrap_or()

const endpoint unwrap_or ( DEFAULT_CLOUD_BASE )

Options that drive [run].

The 51Degrees cloud resource key.

An optional override for the cloud endpoint, read from _51DEGREES_CLOUD_ENDPOINT. None selects the public cloud.

The socket address the server binds to.

Variable Documentation

◆ __pad0__

program __pad0__

◆ cloud_base

resource_key cloud_base

◆ DEFAULT_CLOUD_BASE

const DEFAULT_CLOUD_BASE

The public 51Degrees cloud API base the resource script is loaded from when _51DEGREES_CLOUD_ENDPOINT is unset.

The resource script lives at <base><resource-key>.js. Mirrors the cloud request engine default.

◆ tests

mod tests
Initial value:
{
use super::*

◆ web_support

mod web_support