=pod =head1 NAME Moose::Cookbook::Recipe5 =head1 SYNOPSIS package Request; use strict; use warnings; use Moose; use HTTP::Headers (); use Params::Coerce (); use URI (); subtype Header => as Object => where { $_->isa('HTTP::Headers') }; coerce Header => from ArrayRef => via { HTTP::Headers->new( @{ $_ } ) } => from HashRef => via { HTTP::Headers->new( %{ $_ } ) }; subtype Uri => as Object => where { $_->isa('URI') }; coerce Uri => from Object => via { $_->isa('URI') ? $_ : Params::Coerce::coerce( 'URI', $_ ) } => from Str => via { URI->new( $_, 'http' ) }; subtype Protocol => as Str => where { /^HTTP\/[0-9]\.[0-9]$/ }; has 'base' => (is => 'rw', isa => 'Uri', coerce => 1); has 'url' => (is => 'rw', isa => 'Uri', coerce => 1); has 'method' => (is => 'rw', isa => 'Str'); has 'protocol' => (is => 'rw', isa => 'Protocol'); has 'headers' => ( is => 'rw', isa => 'Header', coerce => 1, default => sub { HTTP::Headers->new } ); =head1 DESCRIPTION =head1 AUTHOR Stevan Little Estevan@iinteractive.comE =head1 COPYRIGHT AND LICENSE Copyright 2006 by Infinity Interactive, Inc. L This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut