Skip to content

motemen/Cirdan

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cirdan

Chord の弱ぱくりです

Synopsis

use Cirdan; # Exports routing functions, response functions

routes {
    POST q'/entry'       => *post_entry; # Specify path as string, handler as typeglob
    GET  q'/entry/(\d+)' => *entry;
    ANY  q'/'            => *index;
    ANY  qr//            => sub { NOT_FOUND }; # Specify path as regexp, handler as coderef
};

sub post_entry {
    ...
    return BAD_REQUEST unless ...
    ...
    redirect +Cirdan->router->path_for('index');
}

use Cirdan::View qw(mt); # Exports renderer functions

sub index {
    my $body = mt *DATA, @args;
    return $body;
    # or
    # HTTP status code names are response maker
    # such as CREATED([\@headers,] $content)
    return OK $body;
    return OK [ 'Content-Type' => 'text/xml' ], $body;
}

# Finally...
__PSGI__ # returns PSGI handler

__END__

About

Simple WAF on PSGI

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages