1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
//! Where the app's frontends are reached.
//!
//! [`url`] is a frontend's URL in the environment the code runs in, as to
//! send a user there or to build a link to one of its pages:
//!
//! ```ignore
//! use encore::frontends;
//!
//! let reset = format!("{}/reset?token={token}", frontends::url("web"));
//! ```
//!
//! Looking a frontend's URL up links the calling service to it. Encore reads
//! the link from the code, as it reads which services a service depends on:
//! so the name must be a string literal, written as the frontend declares it,
//! the function must be called directly rather than passed around, and the
//! call must be in a service.
/// The URL `frontend` is reached at in this environment, without a trailing
/// slash: a path goes after it, `{url}/reset`. It is the first of the
/// frontend's origins, as [`crate::env::app_meta`] lists them.
///
/// The name is the one the frontend is declared with, in its
/// `encore.frontend.json` or as the service hosting it: `web_app` does not
/// find `web-app`.
///
/// # Panics
///
/// If the runtime knows no URL for `frontend`: the app has no frontend of that
/// name, which Encore's parser reports, or the environment gives it no
/// origins.