libduvet/api_router

Types

Where the API, the gateway and the other services live.

pub type ApiRouter {
  ApiRouter(
    api: String,
    ws: String,
    base: String,
    cdn: String,
    secure: Bool,
  )
}

Constructors

  • ApiRouter(
      api: String,
      ws: String,
      base: String,
      cdn: String,
      secure: Bool,
    )

    Arguments

    secure

    Whether the API and the gateway are reached over TLS (https, wss), as the hosted ones are; a local server (e.g. localhost:9876) may not be.

Values

pub const api_base_path: String
pub fn custom_api_url(
  router: ApiRouter,
  protocol: String,
) -> String
pub fn default_router() -> ApiRouter

The hosted service.

pub fn encode_component(text: String) -> String

Encodes one path segment, as Dart’s Uri.encodeComponent does: a space is %20, and the unreserved characters stay as they are.

pub fn encode_query_component(text: String) -> String
pub fn query_string(pairs: List(#(String, String))) -> String

Encodes query pairs the way Dart’s Uri.replace(queryParameters:) does: space as +, and everything but the unreserved characters escaped as uppercase UTF-8 percent escapes.

pub fn url_from_path(
  router: ApiRouter,
  path: String,
  query: List(#(String, String)),
) -> String

The API’s URL for [path], whose segments must already be encoded, with [query]’s values; a key repeated repeats in the query.

✨ Search Document