Skip to content

Instantly share code, notes, and snippets.

@ab5tract
Created February 27, 2009 19:37
Show Gist options
  • Save ab5tract/71656 to your computer and use it in GitHub Desktop.
Save ab5tract/71656 to your computer and use it in GitHub Desktop.
# This is my first attempt at p6, and I haven't coded perl since 2000, so be gentle ;)
use v6;
module WavesWorld {
use Waves <compact>;
# Taking advantage of roles and traits as opposed to the module mixin style utilized by Waves
class Map is Resource { # You can imagine roles here too: 'does Media', 'does Reload', etc.
# This is the simplest example, and doesn't pretend to provide the convenience of the Waves routing DSL...
method get {
print "Hello, world!";
}
# ..Which we will contrast in its Ruby form here
# def get { "Hello world" };
# .. and this is the DSL style
# on( :get, true ) { "Hello, world!" }
# 'true' is the wild card, an argument passed to functor saying "Whatever you get as an argument, we match and do the following block"
# on( :get, ['super']) { "Hello, super friend!" }
# the above rule matches '/super' . All other urls would be handled by the previous wildcard.
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment