View Source Imglab.Source (imglab v0.3.0)

Provides a way to define and store information about a imglab source.

Link to this section Summary

Functions

Returns a Source struct with the specified options for the source.

Link to this section Types

@type t() :: %Imglab.Source{
  host: binary(),
  https: boolean(),
  name: binary(),
  port: nil | :inet.port_number(),
  secure_key: nil | binary(),
  secure_salt: nil | binary(),
  subdomains: boolean()
}

Link to this section Functions

Link to this function

new(name, options \\ [])

View Source
@spec new(
  binary(),
  keyword()
) :: t()

Returns a Source struct with the specified options for the source.

name must be a string indicating the name of the source.

options

Options

The accepted options are:

  • :host - a string specifying the host where the imglab server is located, only for imglab on-premises (default: "imglab-cdn.net")
  • :https - a boolean value specifying if the source should use https or not (default: true)
  • :port - a :inet.port_number specifying a port where the imglab server is located, only for imglab on-premises
  • :secure_key - a string specifying the source secure key
  • :secure_salt - a string specifying the source secure salt
  • :subdomains - a boolean value specifying if the source should be specified using subdomains instead of using the path, only for imglab on-premises (default: true)

Note: secure_key and secure_salt parameters are secrets that should not be added to the code. Please use environment vars or other secure method to use them in your project.

examples

Examples

iex> Imglab.Source.new("assets")
%Imglab.Source{
  host: "imglab-cdn.net",
  https: true,
  name: "assets",
  port: nil,
  secure_key: nil,
  secure_salt: nil,
  subdomains: true
}

iex> Imglab.Source.new("assets", subdomains: false)
%Imglab.Source{
  host: "imglab-cdn.net",
  https: true,
  name: "assets",
  port: nil,
  secure_key: nil,
  secure_salt: nil,
  subdomains: false
}

iex> Imglab.Source.new("assets", https: false, host: "imglab.net", port: 8080)
%Imglab.Source{
  host: "imglab.net",
  https: false,
  name: "assets",
  port: 8080,
  secure_key: nil,
  secure_salt: nil,
  subdomains: true
}

iex> Imglab.Source.new("assets", secure_key: "secure-key", secure_salt: "secure-salt")
%Imglab.Source{
  host: "imglab-cdn.net",
  https: true,
  name: "assets",
  port: nil,
  secure_key: "secure-key",
  secure_salt: "secure-salt",
  subdomains: true
}