Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/matsumotory/mruby-httprequest
HttpRequest of iij/mruby support mruby/mruby using mruby-uv and mruby-http
https://github.com/matsumotory/mruby-httprequest
Last synced: about 2 months ago
JSON representation
HttpRequest of iij/mruby support mruby/mruby using mruby-uv and mruby-http
- Host: GitHub
- URL: https://github.com/matsumotory/mruby-httprequest
- Owner: matsumotory
- Created: 2012-12-18T11:16:48.000Z (about 12 years ago)
- Default Branch: master
- Last Pushed: 2018-02-03T15:22:15.000Z (almost 7 years ago)
- Last Synced: 2024-10-18T18:25:47.368Z (3 months ago)
- Language: Ruby
- Size: 12.7 KB
- Stars: 17
- Watchers: 6
- Forks: 9
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# HttpRequest Class for mruby
refactored HttpRequest using mruby-simplehttp and mruby-httporiginal code is iij/mruby
## install by mrbgems
- add conf.gem line to `build_config.rb`
```ruby
MRuby::Build.new do |conf|# ... (snip) ...
conf.gem :mgem => 'mruby-httprequest'
end
```## example
```ruby
class GrowthForecast
DEFAULTADDRESS = "127.0.0.1"
DEFAULTPORT = 5125
class Client
def initialize(address, port)
address = DEFAULTADDRESS if address.nil?
port = DEFAULTPORT if port.nil?
@url = sprintf("http://%s:%s/api", address, port.to_s)
enddef post(config, data)
http = HttpRequest.new()
api_url = sprintf("%s/%s/%s/%s", @url, config[:service], config[:section], config[:gragh])
http.post(api_url, {
:number => data[:number],
:color => data[:color],
:mode => data[:mode],
},{
'User-Agent' => "mruby-growthforecast",
})
end
end
end
```# License
under the MIT License:* http://www.opensource.org/licenses/mit-license.php