View Source Hui.Http.Client behaviour (Hui v0.11.0)

A client behaviour module for handling Solr HTTP requests and responses.

This module is responsible for dispatching Solr request encapsulated in Hui.Http.t/0 struct. It underpins the core functions of Hui. Three implementations have been provided:

using-other-http-clients

Using other HTTP clients

httpc is used in Hui by default. One of the above HTTP clients may be deployed by adding the client as dependency and specificying it via the http_client configuration - see below. Other HTTP clients may also be used by implementing this behaviour.

  config :hui,
    http_client: Hui.Http.Clients.Finch

Hui.Http.Clients.Finch depends on Finch. The dependency needs to be specified in mix.exs. You might also need to start the client application by specifying it (e.g. :httpoison) in the application section of mix.exs.

  defp deps do
    [
      {:finch, "~> 0.16"}
    ]
  end

For Finch (only), you also need to name and start it from your supervision tree and configure it as below:

  # use the same name specified in the supervision tree
  config :hui, :finch, name: FinchSolr

Link to this section Summary

Callbacks

Dispatch HTTP request to a Solr endpoint.

For post-dispatch processing such as error handling and parsing Solr documents.

Link to this section Types

@type http_response() :: {:ok, term()} | {:ok, term()}
@type request() :: Hui.Http.t()
@type response() :: {:ok, Hui.Http.t()} | {:error, Hui.Error.t()}

Link to this section Callbacks

@callback dispatch(request()) :: http_response()

Dispatch HTTP request to a Solr endpoint.

If a client is not set via c:build_request/3, the default httpc-based client will be used.

Link to this callback

handle_response(http_response, request)

View Source
@callback handle_response(http_response(), request()) :: response()

For post-dispatch processing such as error handling and parsing Solr documents.

Link to this section Functions

@spec dispatch(request()) :: response()
Link to this function

handle_response(resp, request)

View Source
@spec handle_response(http_response(), request()) :: response()
@spec impl() :: module()