Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Catalyst: Users

REST and text/html not supported

 

 

Catalyst users RSS feed   Index | Next | Previous | View Threaded


ankolev at gmail

Jun 29, 2009, 1:37 PM

Post #1 of 4 (506 views)
Permalink
REST and text/html not supported

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi all
i have controller Myapp::Controller::Offers with "use parent
'Catalyst::Controller::REST'" where all RESTed requests works fine, but
then i have Myapp::Controller::Offers::Create where i dont want
C::C::REST to work, because when i send common form with content type
'application/x-www-form-urlencoded' to /offers/create/done i recieve 415
"Content-Type text/html is not supported". The "done" method is:
sub done: Local: ActionClass('RenderView')
I dont want this controller to be RESTish or atleast how i can enable
text/html content types here?
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkpJJekACgkQlAw25U6UlpCgsQCfWamzBWlE/tU2eMHbnb9HHv6s
KRQAnRMAnF6Sjf2RO6gGH9gaEJpzSTqa
=wwA/
-----END PGP SIGNATURE-----

_______________________________________________
List: Catalyst[at]lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst[at]lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


alejandro.imass at gmail

Jun 29, 2009, 1:49 PM

Post #2 of 4 (473 views)
Permalink
Re: REST and text/html not supported [In reply to]

You can override the default serializers:

__PACKAGE__->config(
'default' => 'application/json',
'stash_key' => 'rest',
'map' => {
'text/html' => [ 'View', 'TT', ],
'text/xml' => [ 'View', 'TT', ],
},
);


On Tue, Jun 30, 2009 at 4:07 PM, Angel Kolev<ankolev[at]gmail.com> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hi all
> i have controller Myapp::Controller::Offers with "use parent
> 'Catalyst::Controller::REST'" where all RESTed requests works fine, but
> then i have Myapp::Controller::Offers::Create where i dont want
> C::C::REST to work, because when i send common form with content type
> 'application/x-www-form-urlencoded' to /offers/create/done i recieve 415
> "Content-Type text/html is not supported". The "done" method is:
> sub done: Local: ActionClass('RenderView')
> I dont want this controller to be RESTish or atleast how i can enable
> text/html content types here?
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.9 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>
> iEYEARECAAYFAkpJJekACgkQlAw25U6UlpCgsQCfWamzBWlE/tU2eMHbnb9HHv6s
> KRQAnRMAnF6Sjf2RO6gGH9gaEJpzSTqa
> =wwA/
> -----END PGP SIGNATURE-----
>
> _______________________________________________
> List: Catalyst[at]lists.scsys.co.uk
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive: http://www.mail-archive.com/catalyst[at]lists.scsys.co.uk/
> Dev site: http://dev.catalyst.perl.org/
>

_______________________________________________
List: Catalyst[at]lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst[at]lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


ankolev at gmail

Jun 29, 2009, 1:58 PM

Post #3 of 4 (471 views)
Permalink
Re: REST and text/html not supported [In reply to]

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Thanks! Now it works.

Alejandro Imass wrote:
> You can override the default serializers:
>
> __PACKAGE__->config(
> 'default' => 'application/json',
> 'stash_key' => 'rest',
> 'map' => {
> 'text/html' => [ 'View', 'TT', ],
> 'text/xml' => [ 'View', 'TT', ],
> },
> );
>
>
> On Tue, Jun 30, 2009 at 4:07 PM, Angel Kolev<ankolev[at]gmail.com> wrote:
> Hi all
> i have controller Myapp::Controller::Offers with "use parent
> 'Catalyst::Controller::REST'" where all RESTed requests works fine, but
> then i have Myapp::Controller::Offers::Create where i dont want
> C::C::REST to work, because when i send common form with content type
> 'application/x-www-form-urlencoded' to /offers/create/done i recieve 415
> "Content-Type text/html is not supported". The "done" method is:
> sub done: Local: ActionClass('RenderView')
> I dont want this controller to be RESTish or atleast how i can enable
> text/html content types here?
>>
_______________________________________________
List: Catalyst[at]lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst[at]lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkpJKvsACgkQlAw25U6UlpDefACgpRwH5cuOQAKFSNLM4Ha8HKT3
2xAAn3x+1IoEXq8NW009kf9ABk0xpFsU
=DxEk
-----END PGP SIGNATURE-----

_______________________________________________
List: Catalyst[at]lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst[at]lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


alejandro.imass at gmail

Jun 29, 2009, 2:31 PM

Post #4 of 4 (467 views)
Permalink
Re: REST and text/html not supported [In reply to]

Yeah, nowadays it's confusing between XHTML and HTML so just use TT
both and you're covered, unless you have special XML needs and have to
discriminate. In any case you can forward to a private sub like so:

sub collection :Local :ActionClass('REST') {
my ( $self, $c ) = @_;
unless($c->forward('check_headers')){
$self->status_bad_request(
$c,
message => 'BAD HEADERS',
);
return;
}
}

sub check_headers : Private {
my ( $self, $c ) = @_;

my $accept = $c->req->header('accept');
return undef unless $accept;

if($accept =~ m/html/){
$c->req->header('accept' => 'text/html');

}
elsif($accept =~ m/xml/){
$c->req->header('accept' => 'text/xml');
$c->stash->{template} = $c->action.'.xml';
}

return 1;

}

YMMV,

Alex


On Tue, Jun 30, 2009 at 4:28 PM, Angel Kolev<ankolev[at]gmail.com> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Thanks! Now it works.
>
> Alejandro Imass wrote:
>> You can override the default serializers:
>>
>> __PACKAGE__->config(
>> 'default' => 'application/json',
>> 'stash_key' => 'rest',
>> 'map' => {
>> 'text/html' => [ 'View', 'TT', ],
>> 'text/xml' => [ 'View', 'TT', ],
>> },
>> );
>>
>>
>> On Tue, Jun 30, 2009 at 4:07 PM, Angel Kolev<ankolev[at]gmail.com> wrote:
>> Hi all
>> i have controller Myapp::Controller::Offers with "use parent
>> 'Catalyst::Controller::REST'" where all RESTed requests works fine, but
>> then i have Myapp::Controller::Offers::Create where i dont want
>> C::C::REST to work, because when i send common form with content type
>> 'application/x-www-form-urlencoded' to /offers/create/done i recieve 415
>> "Content-Type text/html is not supported". The "done" method is:
>> sub done: Local: ActionClass('RenderView')
>> I dont want this controller to be RESTish or atleast how i can enable
>> text/html content types here?
>>>
> _______________________________________________
> List: Catalyst[at]lists.scsys.co.uk
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive: http://www.mail-archive.com/catalyst[at]lists.scsys.co.uk/
> Dev site: http://dev.catalyst.perl.org/
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.9 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>
> iEYEARECAAYFAkpJKvsACgkQlAw25U6UlpDefACgpRwH5cuOQAKFSNLM4Ha8HKT3
> 2xAAn3x+1IoEXq8NW009kf9ABk0xpFsU
> =DxEk
> -----END PGP SIGNATURE-----
>
> _______________________________________________
> List: Catalyst[at]lists.scsys.co.uk
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive: http://www.mail-archive.com/catalyst[at]lists.scsys.co.uk/
> Dev site: http://dev.catalyst.perl.org/
>

_______________________________________________
List: Catalyst[at]lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst[at]lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/

Catalyst users RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.