Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/AlexWayfer/faraday-encode_xml
Faraday middleware for encoding requests as XML
https://github.com/AlexWayfer/faraday-encode_xml
Last synced: about 2 months ago
JSON representation
Faraday middleware for encoding requests as XML
- Host: GitHub
- URL: https://github.com/AlexWayfer/faraday-encode_xml
- Owner: AlexWayfer
- License: mit
- Created: 2021-09-21T20:13:46.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-07-04T07:00:18.000Z (6 months ago)
- Last Synced: 2024-07-07T14:05:44.863Z (6 months ago)
- Language: Ruby
- Size: 90.8 KB
- Stars: 1
- Watchers: 3
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
- awesome-faraday - encode_xml - encode XML requests (responses decoding is included in `faraday_middleware` gem) (Middleware)
README
# Faraday Encode XML
[![Cirrus CI - Base Branch Build Status](https://img.shields.io/cirrus/github/AlexWayfer/faraday-encode_xml?style=flat-square)](https://cirrus-ci.com/github/AlexWayfer/faraday-encode_xml)
[![Codecov branch](https://img.shields.io/codecov/c/github/AlexWayfer/faraday-encode_xml/main.svg?style=flat-square)](https://codecov.io/gh/AlexWayfer/faraday-encode_xml)
[![Code Climate](https://img.shields.io/codeclimate/maintainability/AlexWayfer/faraday-encode_xml.svg?style=flat-square)](https://codeclimate.com/github/AlexWayfer/faraday-encode_xml)
[![Depfu](https://img.shields.io/depfu/AlexWayfer/faraday-encode_xml?style=flat-square)](https://depfu.com/repos/github/AlexWayfer/faraday-encode_xml)
[![Gem](https://img.shields.io/gem/v/faraday-encode_xml.svg?style=flat-square)](https://rubygems.org/gems/faraday-encode_xml)
[![License](https://img.shields.io/github/license/AlexWayfer/faraday-encode_xml.svg?style=flat-square)](LICENSE.txt)This repo is a [Faraday](https://github.com/lostisland/faraday) middleware for encoding requests as XML.
Faraday is an HTTP client library that provides a common interface for making requests.## Installation
Add this line to your application's Gemfile:
```ruby
gem 'faraday-encode_xml'
```And then execute:
```shell
bundle install
```Or install it yourself as:
```shell
gem install faraday-encode_xml
```## Usage
```ruby
require 'faraday/encode_xml'connection = Faraday.new do |faraday|
## This gem only encodes requests
faraday.request :xml## For responses deconding use `faraday_middleware` gem and such code:
# require 'faraday_middleware'
# faraday.response :xml## For example `httpbingo` responses as JSON, so let's enable it:
require 'faraday_middleware'
faraday.response :json
endresponse = connection.post('https://httpbingo.org/post', { a: 1, b: 'foo', c: true })
puts response.body['data'] ## => 1footrue
```### Gyoku options
The middleware uses [`gyoku` gem](https://rubygems.org/gems/gyoku) for XML encoding.
You can pass options for it:
```ruby
connection = Faraday.new do |faraday|
## https://www.rubydoc.info/gems/gyoku/#array-values
faraday.request :xml, gyoku_options: { unwrap: true }
end
```## Development
After checking out the repo, run `bundle install` to install dependencies.
Then, run `bundle exec rspec` to run the tests.
To install this gem onto your local machine, run `toys gem install`.
To release a new version, run `toys gem release %version%`.
See how it works [here](https://github.com/AlexWayfer/gem_toys#release).## Contributing
Bug reports and pull requests are welcome on [GitHub](https://github.com/AlexWayfer/faraday-encode_xml).
## License
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).