This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// server | |
var express = require('express') | |
, fs = require('fs') | |
, http = require('http') | |
, path = require('path') | |
, barrister = require('barrister') | |
, store = require("./store").store | |
, idl = JSON.parse(fs.readFileSync("./todo_manager.json").toString()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"id":1, | |
"age":32, | |
"importance_level":100, | |
"alias":"hippipp", | |
"full_name":"S-H, Erin", | |
"url":"http://example.com/api/v1/contacts/1.json" | |
} | |
] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Verb | URI Pattern | | |
| -------| ------------------------------------------- | | |
| GET | http://example.com/api/v1/contacts.json | | |
| POST | http://example.com/api/v1/contacts.json | | |
| GET | http://example.com/api/v1/contacts/:id.json | | |
| PATCH | http://example.com/api/v1/contacts/:id.json | | |
| DELETE | http://example.com/api/v1/contacts/:id.json | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Contact < ActiveRecord::Base | |
validates :full_name, presence: true | |
validates :alias, presence: true | |
validates :importance_level, inclusion: { | |
in: [100, 200, 300] | |
} | |
validates :age, numericality: { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"first_name":["can't be blank"], | |
"last_name":["can't be blank"] | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl -X POST \ | |
-H "Content-Type: application/json" \ | |
-d '{"full_name": "Erin S-H", "age": 32, "importance_level": 100, "alias": "laser"}' \ | |
http://example.com/api/v1/contacts.json |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl -X POST \ | |
-H "Content-Type: application/json" \ | |
-d '{"first_name": "Erin", "last_name": "S-H", "age": 32, "importance_level": 100, "alias": "lzr"}' \ | |
http://example.com/api/v1/contacts.json |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Contact Service API Reference | |
/api/v1/contacts.json | |
## Reading | |
GET /contacts.json HTTP/1.1 | |
Host: example.com | |
### Fields |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'net/http' | |
require 'securerandom' | |
require 'json' | |
require 'benchmark' | |
require 'redis' | |
require 'bunny' | |
require 'pry' | |
uri = URI('http://localhost:4567/calc') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Rehearsal -------------------------------------------- | |
RabbitMQ 0.980000 0.570000 1.550000 ( 1.602346) | |
Redis 0.280000 0.040000 0.320000 ( 0.419955) | |
HTTP 0.500000 0.200000 0.700000 ( 2.436720) | |
----------------------------------- total: 2.570000sec | |
user system total real | |
RabbitMQ 0.980000 0.580000 1.560000 ( 1.604432) | |
Redis 0.270000 0.040000 0.310000 ( 0.416424) | |
HTTP 0.490000 0.190000 0.680000 ( 6.691767) |