Skip to content

Instantly share code, notes, and snippets.

@jkramer jkramer/blurgh.p6
Created Aug 3, 2016

What would you like to do?
Blurgh Example
use Blurgh;
class Blog::Post does Blurgh::Route[:('post')] {
state %posts;
state $next-post-id = 1;
# Matches "GET /post/123" (only if integer exists in %posts)
multi method get(Int:D $id where { %posts{$_}:exists }) {
# Matches POST /post/new
multi method post('new') {
my $id = $next-post-id++;
%posts{$id} = $;
$.render(:text("post $id created"));
# curl -d 'Lustiger Post.' localhost:8118/post/new
post 1 created
# curl localhost:8118/post/1
Lustiger Post
# curl localhost:8118/post/2
Not Found
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.