Short v0.0.1 Short.Adapter behaviour View Source

Behaviour for creating a Short adapter.

The easiest way to create a Short Adapter is to use the Short.Adapter and then implement the get/1 and create/2 callbacks. See Short.Adapters.InMemory for an example.

Link to this section Summary

Types

The code representing the shortened URL

Possible errors occuring when working with Short Codes

A wrapper around a shortened URL

The URL to be shortened

Callbacks

Shortens an URL with the given code or a generated one

Retrieve a URL from the adapter

Link to this section Types

The code representing the shortened URL

Possible errors occuring when working with Short Codes.

Link to this type shortened_url() View Source
shortened_url() :: {code, url}

A wrapper around a shortened URL.

The URL to be shortened

Link to this section Callbacks

Link to this callback create(url, arg1) View Source
create(url, code | nil) ::
  {:ok, shortened_url} |
  {:error, error}

Shortens an URL with the given code or a generated one.

Returns the URL and the Code or an error when failing to shorten the URL.

Link to this callback get(code) View Source
get(code) :: {:ok, url} | {:error, error}

Retrieve a URL from the adapter.

Returns the URL or an error when failing to retrieve the URL.