Open
Description
It's a common form to want to return
a newly-constructed object with all the values set into it already, by having mutator methods that return the invocant, so you can easily add more. In such a style you could write:
return HTTP::Response->new( 200 )
->set_content_type( "text/plain" )
->set_content( "Hello, world" );
As it currently stands, the existing mutator methods like ->header
, ->content
, etc.. do not return the invocant, thus such a style is impossible and one must use a temporary:
my $resp = HTTP::Response->new( 200 );
$resp->content_type( "text/plain" );
$resp->content( "Hello, world" );
return $resp;
Metadata
Metadata
Assignees
Labels
No labels