1Dancer::Response(3)   User Contributed Perl Documentation  Dancer::Response(3)
2
3
4

NAME

6       Dancer::Response - Response object for Dancer
7

VERSION

9       version 1.3512
10

SYNOPSIS

12           # create a new response object
13           Dancer::Response->new(
14               status => 200,
15               content => 'this is my content'
16           );
17
18           Dancer::SharedData->response->status; # 200
19
20           # fetch current response object
21           my $response = Dancer::SharedData->response;
22
23           # fetch the current status
24           $response->status; # 200
25
26           # change the status
27           $response->status(500);
28

PUBLIC API

30   new
31           Dancer::Response->new(
32               status  => 200,
33               content => 'my content',
34               headers => ['X-Foo' => 'foo-value', 'X-Bar' => 'bar-value'],
35           );
36
37       create and return a new Dancer::Response object
38
39   current
40           my $response = Dancer::SharedData->response->current();
41
42       return the current Dancer::Response object, and reset the object
43
44   exists
45           if ($response->exists) {
46               ...
47           }
48
49       test if the Dancer::Response object exists
50
51   content
52           # get the content
53           my $content = $response->content;
54           my $content = Dancer::SharedData->response->content;
55
56           # set the content
57           $response->content('my new content');
58           Dancer::SharedData->response->content('my new content');
59
60       set or get the content of the current response object
61
62   status
63           # get the status
64           my $status = $response->status;
65           my $status = Dancer::SharedData->response->status;
66
67           # set the status
68           $response->status(201);
69           Dancer::SharedData->response->status(201);
70
71       Set or get the status of the current response object.  The default
72       status is 200.
73
74   content_type
75           # get the status
76           my $ct = $response->content_type;
77           my $ct = Dancer::SharedData->response->content_type;
78
79           # set the status
80           $response->content_type('application/json');
81           Dancer::SharedData->response->content_type('application/json');
82
83       Set or get the status of the current response object.
84
85   pass
86           $response->pass;
87           Dancer::SharedData->response->pass;
88
89       Set the pass value to one for this response.
90
91   has_passed
92           if ($response->has_passed) {
93               ...
94           }
95
96           if (Dancer::SharedData->response->has_passed) {
97               ...
98           }
99
100       Test if the pass value is set to true.
101
102   halt($content)
103           Dancer::SharedData->response->halt();
104           $response->halt;
105
106       Stops the processing of the current request.  See "halt" in Dancer.
107
108   halted
109           if (Dancer::SharedData->response->halted) {
110              ...
111           }
112
113           if ($response->halted) {
114               ...
115           }
116
117       This flag will be true if the current response has been halted.
118
119   header
120           # set the header
121           $response->header('X-Foo' => 'bar');
122           Dancer::SharedData->response->header('X-Foo' => 'bar');
123
124           # get the header
125           my $header = $response->header('X-Foo');
126           my $header = Dancer::SharedData->response->header('X-Foo');
127
128       Get or set the value of a header.
129
130   headers
131           $response->headers('X-Foo' => 'fff', 'X-Bar' => 'bbb');
132           Dancer::SharedData->response->headers('X-Foo' => 'fff', 'X-Bar' => 'bbb');
133
134       Return the list of headers for the current response.
135
136   headers_to_array
137           my $headers_psgi = $response->headers_to_array();
138           my $headers_psgi = Dancer::SharedData->response->headers_to_array();
139
140       This method is called before returning a PSGI response. It transforms
141       the list of headers to an array reference.
142

AUTHOR

144       Dancer Core Developers
145
147       This software is copyright (c) 2010 by Alexis Sukrieh.
148
149       This is free software; you can redistribute it and/or modify it under
150       the same terms as the Perl 5 programming language system itself.
151
152
153
154perl v5.28.1                      2019-03-31               Dancer::Response(3)
Impressum