Create a gist now

Instantly share code, notes, and snippets.

Weasel Diesel API example
describe_service "hello_world" do |service|
service.formats :json
service.http_verb :get
service.disable_auth # on by default
# INPUT
service.param.string :name, :default => 'World'
# OUTPUT
service.response do |response|
response.object do |obj|
obj.string :message, :doc => "The greeting message sent back. Defaults to 'World'"
obj.datetime :at, :doc => "The timestamp of when the message was dispatched"
end
end
# DOCUMENTATION
service.documentation do |doc|
doc.overall "This service provides a simple hello world implementation example."
doc.param :name, "The name of the person to greet."
doc.example "<code>curl -I 'http://localhost:9292/hello_world?name=Matt'</code>"
end
# ACTION/IMPLEMENTATION
service.implementation do
{:message => "Hello #{params[:name]}", :at => Time.now}.to_json
end
end
@jmazzi
jmazzi commented Apr 4, 2012

The indentation is off on line 13

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment