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
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 |
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 | |
# 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) |
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
barrister -j todo_manager.json todo_manager.idl |
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 --data-urlencode \ | |
idl@todo_manager.idl \ | |
http://barrister.bitmechanic.com/run > todo_manager.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
struct TodoProperties { | |
title string | |
completed bool | |
} | |
struct Todo extends TodoProperties { | |
id int | |
} | |
interface TodoManager { |
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 python | |
import barrister | |
from bottle import run, post, request | |
from store import Store, RecordNotFound, UserDataInvalid, MaxTodosExceeded | |
from functools import wraps | |
import sys | |
import code | |
class TodoManager(object): |
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 python | |
import barrister | |
import sys | |
from bottle import run, post, request | |
from store import Store, RecordNotFound, UserDataInvalid, MaxTodosExceeded | |
from functools import wraps | |
def guard(*exceptions): | |
errors = { |
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
[dev]$ pip install barrister | |
Downloading/unpacking barrister | |
Downloading barrister-0.1.6.tar.gz | |
Running setup.py (path:/private/var/folders/lb/v0d4zb6j6z39m7vfzc4vb47h0000gn/T/pip_build_erinswenson-healey/barrister/setup.py) egg_info for package barrister | |
Downloading/unpacking Markdown (from barrister) | |
Downloading Markdown-2.4.tar.gz (260kB): 260kB downloaded | |
Running setup.py (path:/private/var/folders/lb/v0d4zb6j6z39m7vfzc4vb47h0000gn/T/pip_build_erinswenson-healey/Markdown/setup.py) egg_info for package Markdown | |
Downloading/unpacking plex (from barrister) |
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
[dev]$ pip install barrister | |
Downloading/unpacking barrister | |
Downloading barrister-0.1.6.tar.gz | |
Running setup.py (path:/private/var/folders/lb/v0d4zb6j6z39m7vfzc4vb47h0000gn/T/pip_build_erinswenson-healey/barrister/setup.py) egg_info for package barrister | |
Downloading/unpacking Markdown (from barrister) | |
Downloading Markdown-2.4.tar.gz (260kB): 260kB downloaded | |
Running setup.py (path:/private/var/folders/lb/v0d4zb6j6z39m7vfzc4vb47h0000gn/T/pip_build_erinswenson-healey/Markdown/setup.py) egg_info for package Markdown | |
Downloading/unpacking plex (from barrister) |
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
// Barrister Client Initialization | |
function initApp(callback) { | |
var client = Barrister.httpClient({ | |
'endpoint': '/todos', | |
'interfaces': ['TodoManager'] | |
}); | |
client.loadContract(function() { | |
var proxy = client.proxy('TodoManager'); |