[dancer-users] Examining incoming POST headers.

Naveed Massjouni naveed at vt.edu
Sat Jul 18 06:35:44 BST 2015


On Thu, Jul 16, 2015 at 9:08 PM, Vincent Freeman <ml at felicis.net> wrote:
>
> Hi guys,
>
> I'm new to Dancer2 and I'm trying to access an authorization header, similar to Github's 'X-Hub-Signature'.
>
> I consulted with https://metacpan.org/pod/distribution/Dancer2/lib/Dancer2/Manual.pod#header,it says to use 'headers' to "Adds custom headers to responses" and 'header' to "adds a custom header to response", but it does not say how to retrieve the header information, rather than adding it.
>
> I'm using starman with nginx as the forward proxy.
>
> This is my code for testing header access:
>
> post '//hook' => sub {
>         my $hd = header "Content-Type";;
>         "Your Headers: [".$hd."]";
> };

The header keyword is for setting a header. I think you want:

    my $hd = request->header('Content-Type');

See: https://metacpan.org/pod/Dancer2::Core::Request

-Naveed Massjouni

>
> When I issue a curl, it returns empty.
>
> What am I doing wrong?
>
> Feedback welcomed and thanked in advance.
>
> Cheers,
>
> Vince.
> _______________________________________________
> dancer-users mailing list
> dancer-users at dancer.pm
> http://lists.preshweb.co.uk/mailman/listinfo/dancer-users


More information about the dancer-users mailing list