dotfiles

My personal shell configs and stuff
git clone git://git.alex.balgavy.eu/dotfiles.git
Log | Files | Refs | Submodules | README | LICENSE

ruby.snippets (551B)


      1 snippet http_post "Post request with Net::HTTP" b
      2 headers = {'X-Accept' => 'application/json', 'Accept' => 'application/json', 'Content-Type' => 'application/json; charset=UTF8'}
      3 data = {${1:param_1}: ${2:value_1}}
      4 response = Net::HTTP.post URI(${3:destination url}), data.to_json, headers
      5 if response.code == '200'
      6   ${4:# code if OK}
      7 else
      8   ${5:# code if not}
      9 end
     10 endsnippet
     11 
     12 snippet http_get "Get request with open-uri" b
     13 headers = {'Accept' => 'application/json'}
     14 response = URI.open(${1:url}, headers)
     15 body = JSON.parse(response.read)
     16 endsnippet