mruby-smallhttp for mruby
mruby-smallhttp it's small http lib for MRuby
- add conf.gem line to
build_config.rb
MRuby::Build.newdo |conf|
conf.gem:mgem=>'mruby-smallhttp'end# GET RequestHTTP.new("https://example.com/api/v1/users").get#=> response# POST Requestdata={name: 'value'}headers={'Content-Type'=>'application/json'}HTTP.new("https://example.com/api/v1/users").post(data,headers)#=> response# PUT Requesthttp=HTTP.new("https://example.com/api/v1/users/1")http.put(data,headers)# DELETE Requesthttp=HTTP.new("https://example.com/api/v1/users/1")http.delete(data,headers)#=> response# HEAD & OPTIONS Requesthttp=HTTP.new("https://example.com/api/v1/users/1")http.request("HEAD",body,header)#=> response# How to send file in post requestbody={name: 'value',file: File.read('filename')}header={'Content-Type'=>'multipart/form-data'}http=HTTP.new("https://example.com/api/v1/users/1")http.post(body,header)#=> responseContent-Type supported: application/json, application/x-www-form-urlencoded, multipart/form-data and text/plain
under the MIT License:
- see LICENSE file