Skip to content

Instantly share code, notes, and snippets.

@laser
laser / todo_manager.v1.idl
Created May 2, 2014 21:18
Todo Manager V1 IDL
struct TodoProperties {
title string
completed bool
}
struct Todo extends TodoProperties {
id int
}
interface TodoManager {
@laser
laser / hosted_compiler.sh
Created May 2, 2014 21:21
Using the Barrister Hosted Compiler
curl --data-urlencode \
idl@todo_manager.idl \
http://barrister.bitmechanic.com/run > todo_manager.json
@laser
laser / local_barrister.sh
Created May 2, 2014 21:21
Using the Barrister Binary
barrister -j todo_manager.json todo_manager.idl
@laser
laser / error_code.rb
Last active August 29, 2015 14:00
Barrister Error Code (Ruby)
#!/usr/bin/env ruby
# Client sends invalid parameters to server
require 'barrister'
trans = Barrister::HttpTransport.new("http://localhost:3000/v1/todos")
client = Barrister::Client.new(trans)
client.TodoManager.deleteTodo(45) # valid (45 is an int)
@laser
laser / todo_manager.v2.idl
Created May 2, 2014 21:31
TodoManager V2 IDL
interface TodoManager {
// returns all Todos
readTodos() []Todo
// creates new Todo and returns it with an id
createTodo(todo TodoProperties) Todo
// updates Todo and returns it
updateTodo(todo Todo) Todo
@laser
laser / legacy_api.py
Created May 2, 2014 21:32
Legacy API Version Support (Python)
#!/usr/bin/env python
import barrister
from bottle import run, post, request
from store import Store
from functools import wraps
import sys
class TodoManager:
@laser
laser / outbound_request.json
Created May 2, 2014 21:40
Outbound JSON-RPC 2.0 Request
{
"jsonrpc":"2.0",
"id":"bv0D1yRJhkABZ3fx8ofU",
"method":"TodoManager.createTodo",
"params":[
{
"title":"Call Dad",
"completed":false
}
]
@laser
laser / server.go
Created May 12, 2014 20:16
Basic Server - Golang
package main
import (
t "./todos"
"fmt"
"github.com/coopernurse/barrister-go"
"net/http"
)
type TodoManagerImpl struct {
@laser
laser / server.js
Created May 12, 2014 20:17
Basic Server - Node.js
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.v1.json").toString());
var app = express();
@laser
laser / server.py
Last active August 29, 2015 14:01
Basic Server - Python
#!/usr/bin/env python
import barrister
from bottle import run, post, request
from store import Store
from functools import wraps
import sys
class TodoManager(object):