Sha256: af52afac71903c69d8c423d99aa8e69c76e54c8d39a0c6d7690bb7a3921427ae

Contents?: true

Size: 1.77 KB

Versions: 47

Compression:

Stored size: 1.77 KB

Contents

Configuration
===

## Configure LHC on initialisation

If you want to configure LHC on initialisation (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 initialisation 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, url, 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

47 entries across 47 versions & 1 rubygems

Version Path
lhc-6.7.2 docs/configuration.md
lhc-6.7.1 docs/configuration.md
lhc-6.7.0 docs/configuration.md
lhc-6.6.0.zipkin.pre.03 docs/configuration.md
lhc-6.6.0.zipkin.pre.02 docs/configuration.md
lhc-6.6.0.zipkin.pre.01 docs/configuration.md
lhc-6.6.0.zipkin.pre docs/configuration.md
lhc-6.6.0 docs/configuration.md
lhc-6.5.0 docs/configuration.md
lhc-6.4.0 docs/configuration.md
lhc-6.3.1 docs/configuration.md
lhc-6.3.0 docs/configuration.md
lhc-6.2.0 docs/configuration.md
lhc-6.1.3 docs/configuration.md
lhc-6.1.2 docs/configuration.md
lhc-6.1.1 docs/configuration.md
lhc-6.1.0 docs/configuration.md
lhc-6.0.1 docs/configuration.md
lhc-6.0.0 docs/configuration.md
lhc-5.1.1 docs/configuration.md