Skip to main content

callback_url

Function callback_url 

Source
pub fn callback_url(
    base: &str,
    prefix: &str,
    callback_id: &str,
    action: &str,
) -> String
Expand description

Build the URL for a given callback action.

base is the externally-reachable URL of the receiver (e.g. https://awa.example.com). prefix is mounted under that base; an empty or whitespace-only prefix is permitted for receivers that expose the callback routes at the root. The output is normalized so callers cannot produce double slashes or accidentally drop the leading /:

  • base has any trailing / stripped.
  • prefix is trimmed of surrounding whitespace and trailing /s; if it is non-empty and does not already start with /, one is prepended.
  • action is appended verbatim — pass "complete", "fail", or "heartbeat".
let url = callback_url(
    "https://awa.example.com",
    DEFAULT_CALLBACK_PATH_PREFIX,
    "550e8400-e29b-41d4-a716-446655440000",
    "complete",
);
assert_eq!(
    url,
    "https://awa.example.com/api/callbacks/550e8400-e29b-41d4-a716-446655440000/complete",
);