Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/blendle/excon-addressable
Sets Addressable as the default URI parser. Supports parsing templated uris.
https://github.com/blendle/excon-addressable
excon
Last synced: 2 days ago
JSON representation
Sets Addressable as the default URI parser. Supports parsing templated uris.
- Host: GitHub
- URL: https://github.com/blendle/excon-addressable
- Owner: blendle
- License: mit
- Created: 2016-05-17T17:11:59.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-06-08T12:50:46.000Z (over 6 years ago)
- Last Synced: 2024-11-29T15:52:46.383Z (26 days ago)
- Topics: excon
- Language: Ruby
- Homepage:
- Size: 25.4 KB
- Stars: 3
- Watchers: 8
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.txt
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# Excon::Addressable [![wercker status](https://app.wercker.com/status/3868c162aa140566b830f517c45d528a/s/master "wercker status")](https://app.wercker.com/project/bykey/3868c162aa140566b830f517c45d528a)
Sets [Addressable][addressable] as the default URI parser. Supports parsing
[templated uris][].## Installation
Add this line to your application's Gemfile:
```ruby
gem 'excon-addressable'
```And then execute:
```shell
bundle
```Or install it yourself as:
```shell
gem install excon-addressable
```## Usage
Be sure to add `Excon::Addressable::Middleware` to the top of the middleware
stack, so that the variables get expanded as early as possible. This prevents
other middleware from choking on non-valid URIs.```ruby
Excon.defaults[:middlewares].unshift(Excon::Addressable::Middleware)
```Then simply provide a templated variable, and the values with which to expand
the template:```ruby
conn = Excon.new('http://www.example.com/{uid}', expand: { uid: 'hello' })
conn.request.path # => '/hello'
```## License
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
[addressable]: https://github.com/sporkmonger/addressable
[templated uris]: https://github.com/sporkmonger/addressable#uri-templates