Skip to content

Instantly share code, notes, and snippets.

@mattetti
Created April 4, 2012 10:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mattetti/2300131 to your computer and use it in GitHub Desktop.
Save mattetti/2300131 to your computer and use it in GitHub Desktop.
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
Copy link

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