Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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

Awesome Lists containing this project

README

        

# HttpRequest Class for mruby
refactored HttpRequest using mruby-simplehttp and mruby-http

original 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)
end

def 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