ICouch v0.2.1 ICouch.Server View Source

Holds information about CouchDB server connections and encapsulates API calls.

Link to this section Summary

Functions

Encodes CouchDB style query options together with an endpoint and returns the resulting relative URI

Invokes an arbitrary CouchDB API call which may or may not be implementation specific

Invokes an arbitrary CouchDB API call which may or may not be implementation specific

Link to this section Types

Link to this type body() View Source
body ::
  nil |
  binary |
  (() -> {:ok, binary} | :eof) |
  (state :: term -> {:ok, binary, new_state :: term} | :eof)
Link to this type endpoint() View Source
endpoint ::
  String.t |
  URI.t |
  {String.t | URI.t, options :: Keyword.t | %{optional(atom) => term}}
Link to this type method() View Source
method ::
  :get |
  :post |
  :head |
  :options |
  :put |
  :patch |
  :delete |
  :trace |
  :mkcol |
  :propfind |
  :proppatch |
  :lock |
  :unlock |
  :move |
  :copy
Link to this type option() View Source
option ::
  {:max_sessions, integer} |
  {:max_pipeline_size, integer} |
  {:ssl_options, [any]} |
  {:pool_name, atom} |
  {:proxy_host, String.t} |
  {:proxy_port, integer} |
  {:proxy_user, String.t} |
  {:proxy_password, String.t} |
  {:basic_auth, {username :: String.t, password :: String.t}} |
  {:cookie, String.t} |
  {:http_vsn, {major :: integer, minor :: integer}} |
  {:host_header, String.t} |
  {:timeout, integer} |
  {:inactivity_timeout, integer} |
  {:connect_timeout, integer} |
  {:max_attempts, integer} |
  {:socket_options, [any]} |
  {:worker_process_options, [any]} |
  {:direct_conn_pid, pid}
Link to this type t() View Source
t() :: %ICouch.Server{direct: nil, ib_options: [], timeout: nil, uri: URI.t}

Link to this section Functions

Link to this function endpoint_with_options(endpoint, options \\ []) View Source

Encodes CouchDB style query options together with an endpoint and returns the resulting relative URI.

Link to this function new(uri, options \\ []) View Source
new(uri :: String.t | URI.t, options :: [option]) :: t

See ICouch.server_connection/2.

Link to this function send_raw_req(server, endpoint, method \\ :get, body \\ nil, headers \\ [], ib_options \\ []) View Source
send_raw_req(server :: t, endpoint, method, body, headers :: [{binary, binary}], ib_options :: Keyword.t) ::
  {:ok, {response_headers :: [{binary, binary}], response_body :: binary}} |
  {:ibrowse_req_id, id :: term} |
  {:error, ICouch.RequestError.well_known_error | term}

Invokes an arbitrary CouchDB API call which may or may not be implementation specific.

This expects the request body to be sent as binary (or function yielding binary chunks) and returns the raw response headers and the body as binary. There are no checks made if the request method actually allows a request body.

To use transparent JSON encoding and decoding for the requests use send_req/4.

Link to this function send_req(server, endpoint, method \\ :get, body \\ nil) View Source
send_req(server :: t, endpoint, method, body) ::
  {:ok, body :: term} |
  {:error, ICouch.RequestError.well_known_error | term}

Invokes an arbitrary CouchDB API call which may or may not be implementation specific.

Many functions of the main module make use of this function. It is exposed publicly so you can call arbitrary API functions yourself.

Note that there is transparent JSON encoding and decoding for the requests and the response headers are discarded; if you need raw data or the headers, use send_raw_req/6. Also checks are made if the request method actually allows a request body and discards it if needed.