Sha256: 06f5fe95b01b99e36946a6a7f9e69fb723bf5dfdcba0747be3abced51fb49558

Contents?: true

Size: 1.8 KB

Versions: 21

Compression:

Stored size: 1.8 KB

Contents

Configuration
===

## Configure LHC on initialization

If you want to configure LHC on initialization (like in a Rails initializer, `environment.rb` or `application.rb`), you could run into the problem that certain configurations can only be set once.
You can use `LHC.configure` to prevent the initialization problem.
Take care that you only use `LHC.configure` once, because it is actually reseting previously made configurations and applies the new once.

```ruby

  LHC.configure do |c|
    c.placeholder :datastore, 'http://datastore/v2'
    c.endpoint :feedbacks, '{+datastore}/feedbacks'
    c.interceptors = [CachingInterceptor, MonitorInterceptor, TrackingIdInterceptor]
  end

```

## Endpoints

You can configure endpoints, for later use, by giving them a name, an url and some parameters (optional).

```ruby
  url = 'http://datastore/v2/feedbacks'
  options = { params: { has_reviews: true } }
  LHC.config.endpoint(:feedbacks, url, options)
  LHC.get(:feedbacks)
```

Explicit request options override configured options.

```ruby
  LHC.get(:feedbacks, params: { has_reviews: false }) # Overrides configured params
```

## Placeholders

You can configure global placeholders, that are used when generating urls from url-templates.

```ruby
  LHC.config.placeholder(:datastore, 'http://datastore/v2')
  options = { params: { has_reviews: true } }
  LHC.config.endpoint(:feedbacks, '{+datastore}/feedbacks', options)
  LHC.get(:feedbacks)
```

## Interceptors

To enable interceptors you have to configure LHC's interceptors for http communication.
The global default interceptors are processed in the order you provide them.

```ruby
  LHC.config.interceptors = [CachingInterceptor, MonitorInterceptor, TrackingIdInterceptor]
```

You can only set the list of global interceptors once and you can not alter it after you set it.

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
lhc-9.4.0 docs/configuration.md
lhc-9.3.1 docs/configuration.md
lhc-9.3.0 docs/configuration.md
lhc-9.2.0 docs/configuration.md
lhc-9.1.2 docs/configuration.md
lhc-9.1.2.pre docs/configuration.md
lhc-9.1.1 docs/configuration.md
lhc-8.1.1 docs/configuration.md
lhc-9.1.0 docs/configuration.md
lhc-9.0.0 docs/configuration.md
lhc-8.1.0 docs/configuration.md
lhc-8.0.0 docs/configuration.md
lhc-7.3.3 docs/configuration.md
lhc-7.3.2 docs/configuration.md
lhc-7.3.1 docs/configuration.md
lhc-7.3.0 docs/configuration.md
lhc-7.2.0 docs/configuration.md
lhc-7.1.0 docs/configuration.md
lhc-7.0.1 docs/configuration.md
lhc-7.0.0 docs/configuration.md