# EaseHttp Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/ease_http`. To experiment with that code, run `bin/console` for an interactive prompt. TODO: Delete this and the text above, and describe your gem ## Installation Add this line to your application's Gemfile: ```ruby gem 'ease_http' ``` And then execute: $ bundle Or install it yourself as: $ gem install ease_http ## Usage We have a test sinatra app located in `test/web.rb`, start as our backend server: ```bash # Start test sinatra app ruby test/web.rb # Start console bin/console ``` ### Get ```ruby require 'json' conn = EaseHTTP::Connection.new('http://localhost:4567') # Get with 'query' option res = conn.get '/', query: { hello: 'world' } => # JSON.parse res.body => {"hello": "world"} ``` ### Post ```ruby require 'json' conn = EaseHTTP::Connection.new('http://localhost:4567') # Post with 'data' option as 'application/x-www-form-urlencoded' res = conn.post '/', data: { hello: 'world' } => # JSON.parse res.body => {"hello": "world"} # Post with 'data' option as 'multipart/form-data' file = File.new '/etc/hosts' res = conn.post '/', data: { hello: 'world', file: file } => # JSON.parse res.body => {"hello"=>"world", "file"=> {"filename"=>"hosts", "type"=>"text/plain", "name"=>"file", "tempfile"=>"#", "head"=>"Content-Disposition: form-data; name=\"file\"; filename=\"hosts\"\r\nContent-Type: text/plain\r\n"}} ``` ## Development After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment. To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org). ## Contributing Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/ease_http.