scrapy_cloud_ex v0.1.2 ScrapyCloudEx.Decoder behaviour View Source

Defines the behaviour used to process the body of API responses.

A module implementing this behaviour can be used for decoding API response bodies by using the :decoder key in the opts parameter of every endpoint module.

Link to this section Summary

Types

A function to decode a response body

Callbacks

Decodes the format-encoded body of an API response

Link to this section Types

Link to this type decoder_function() View Source
decoder_function() ::
  (body :: String.t(), format :: format() ->
     {:ok, any()} | ScrapyCloudEx.tagged_error())

A function to decode a response body.

This decoder function will be provided the (uncompressed) reponse body and the requested format. It should return {:ok, term()} | {:error, term()} where :ok and :error indicate whether decoding the body was successful.

Link to this type format() View Source
format() :: :json | :jl | :xml | :csv | :text | :html

Link to this section Callbacks

Link to this callback decode(body, format) View Source
decode(body :: String.t(), format :: format()) ::
  {:ok, any()} | ScrapyCloudEx.tagged_error()

Decodes the format-encoded body of an API response.