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

endpoint.rs File Reference

Functions

pub fn cloud_endpoint_from_env () -> Option< String >
 Read the optional cloud endpoint from [CLOUD_ENDPOINT_ENV_VAR].

Variables

pub const CLOUD_ENDPOINT_ENV_VAR
 Resolution of the optional self-hosted cloud endpoint from the environment.

Function Documentation

◆ cloud_endpoint_from_env()

pub fn cloud_endpoint_from_env ( ) -> Option< String >

Read the optional cloud endpoint from [CLOUD_ENDPOINT_ENV_VAR].

Returns the trimmed value when the variable is set to a non-blank string, or [None] to use the library default. The variable's deprecated name is read when [CLOUD_ENDPOINT_ENV_VAR] is unset or empty. Surrounding whitespace is stripped (a stray space or newline from a shell or .env file is a common slip), so the value passed to the builder is clean.

Only presence and blankness are screened here. The endpoint's URL format (a valid http(s) scheme and host) is validated by the cloud request engine when it builds, so a malformed value surfaces as a clear configuration error rather than a confusing request failure.

Variable Documentation

◆ CLOUD_ENDPOINT_ENV_VAR

pub const CLOUD_ENDPOINT_ENV_VAR

Resolution of the optional self-hosted cloud endpoint from the environment.

The environment variable giving an optional cloud endpoint, used to point the cloud examples at a host other than the public 51Degrees cloud at https://cloud.51degrees.com/api/v4/. This is the same variable the cloud request engine reads as its base URL override, so a single value configures both.

A host other than cloud.51degrees.com would be used to (a) use an on premise web server, or (b) use a privately hosted version of the 51Degrees cloud for performance reasons. This is the private hosting option of the 51Degrees cloud service. Both run the same service as the public cloud, so every example works unchanged against them. Every cloud example in this workspace honours this variable, either by passing [cloud_endpoint_from_env] to its builder or by leaving the endpoint unset so the cloud request engine reads the variable itself, and the value is normalised to end in one /.