Skip to main content

Module gateways

Module gateways 

Source
Expand description

Resolving URLs for the application’s API gateways.

Call url to get a gateway’s public base URL in the current environment, for example to share a webhook or API address with an external client:

ⓘ
use encore::gateways;

let callback = format!("{}/webhooks/stripe", gateways::url("api"));

To call another service inside the application, use crate::services rather than going through a gateway.

Looking up a gateway URL records a dependency from the calling service to that gateway. Because Encore parses this dependency statically, pass the gateway’s declared name as a string literal, call gateways::url directly (rather than through a function pointer), and make the call inside a service.

Functions§

url
Returns the base URL for gateway in the current environment, without a trailing slash (so paths can be appended directly, e.g. {url}/webhooks/stripe).