package Web::Request::Types;
our $AUTHORITY = 'cpan:PTC';
$Web::Request::Types::VERSION = '0.12';
use strict;
use warnings;
# ABSTRACT: package defining subtypes for this distribution

use Moose::Util::TypeConstraints;

class_type('HTTP::Headers');

subtype 'Web::Request::Types::StringLike',
    as 'Object',
    where {
        return unless overload::Method($_, '""');
        my $tc = find_type_constraint('Web::Request::Types::PSGIBodyObject');
        return !$tc->check($_);
    };

duck_type 'Web::Request::Types::PSGIBodyObject' => ['getline', 'close'];

subtype 'Web::Request::Types::PSGIBody',
    as 'ArrayRef[Str|Web::Request::Types::StringLike]|FileHandle|Web::Request::Types::PSGIBodyObject';

subtype 'Web::Request::Types::HTTPStatus',
    as 'Int',
    where { /^[1-5][0-9][0-9]$/ };

subtype 'Web::Request::Types::HTTP::Headers',
    as 'HTTP::Headers';
coerce 'Web::Request::Types::HTTP::Headers',
    from 'ArrayRef',
    via { HTTP::Headers->new(@$_) },
    from 'HashRef',
    via { HTTP::Headers->new(%$_) };

coerce 'Web::Request::Types::PSGIBody',
    from 'Str|Web::Request::Types::StringLike',
    via { [ $_ ] };

1;

__END__

=pod

=encoding UTF-8

=head1 NAME

Web::Request::Types - package defining subtypes for this distribution

=head1 VERSION

version 0.12

=head1 AUTHORS

=over 4

=item *

Jesse Luehrs <doy@tozt.net>

=item *

Paul Cochrane <paul@peateasea.de>

=back

=head1 COPYRIGHT AND LICENSE

This software is copyright (c) 2012--2026 by Jesse Luehrs.

This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.

=cut
