Gorilla Api

Usage in your Rails app

require 'gorillapi'

module Api
  extend Gorillapi
  extend self

  test_api url: 'staging.domain.com'

  header header_name: 'codewranglers.gorillapi',
         api_key:     'ABC123',
         format:       'json',
         version:      1

  def ping
    get "/api/v1/ping"
  end

  def add_task
    post "/api/v1/tasks", params: { task: { name: 'Test Api' } }
  end 
end

Api.add_task # =>


Request Details: Add Task
---------------------------------------------
Url:          staging.domain.com
Request:      POST
Endpoint:     /api/v1/tasks
Content-Type  application/json
Accept:       application/vnd.codewranglers.gorillapi-v1+json
Api Token:    ABC123
Params:       { 'task' => { 'name' => 'Test Api' } }


cURL Request:
---------------------------------------------
curl -X POST -k -i -v -H "Content-Type: application/json" -H "Accept: application/vnd.codewranglers.gorillapi-v1+json" -H "AUTHORIZATION: ABC123"  http://staging.domain.com/api/v1/tasks


Api Call Results:
---------------------------------------------
HTTP/1.1 201 Created
Server: nginx/1.4.7
Date: Wed, 23 Apr 2014 23:33:42 GMT
Content-Type: application/json; charset=utf-8
Transfer-Encoding: chunked
Connection: keep-alive
Status: 201 Created
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
X-Content-Type-Options: nosniff
Vary: Accept-Encoding
ETag: "260ca9dd8a4577fc00b7bd5810298076"
Cache-Control: max-age=0, private, must-revalidate
Set-Cookie: request_method=POST; path=/
X-Request-Id: 75af1009-cd70-4304-9b22-0d7e263ca161
X-Runtime: 0.026264

success