Routemaster Client v0.3.0 Routemaster.Utils View Source

Utility functions.

Link to this section Summary

Functions

Returns a HTTP Authorization header value from the provided plaintext username and password

Returns a formatted and ANSI-escaped string, useful to produce consistent color coded log messages in development

Returns the current time as a unix timestamp

Checks that a URL is valid and has a HTTPS scheme

Link to this section Functions

Link to this function build_auth_header(username, password) View Source
build_auth_header(binary(), binary()) :: binary()

Returns a HTTP Authorization header value from the provided plaintext username and password.

Link to this function debug_message(title, message, color) View Source
debug_message(iodata(), iodata(), atom()) :: iodata()

Returns a formatted and ANSI-escaped string, useful to produce consistent color coded log messages in development.

For example, this code:

Logger.debug fn() ->
  Utils.debug_message(
    "My Context",
    ["A string", ["or", "a"], "IO-list"],
    :red
  )
end

Will produce this logger output in the terminal, with the formatted message coloured in red:

10:00:42.123 [debug] [My Context] A string or a IO-list

Returns the current time as a unix timestamp.

Link to this function valid_url?(url) View Source
valid_url?(binary()) :: boolean()

Checks that a URL is valid and has a HTTPS scheme.