1Dancer::Serializer(3) User Contributed Perl DocumentationDancer::Serializer(3)
2
3
4
6 Dancer::Serializer - serializer wrapper for Dancer
7
9 version 1.3513
10
12 This module is the wrapper that provides support for different
13 serializers.
14
16 Configuration
17 The serializer configuration variable tells Dancer which serializer to
18 use to deserialize request and serialize response.
19
20 You change it either in your config.yml file:
21
22 serializer: "YAML"
23
24 Or in the application code:
25
26 # setting JSON as the default serializer
27 set serializer => 'JSON';
28
29 In your routes you can access parameters just like any route.
30
31 When in a route you return a Perl data structure, it will be serialized
32 automatically to the respective serialized engine (for instance,
33 "JSON").
34
35 For "PUT" and "POST" methods you can access the "request->body" as a
36 string, and you can unserialize it, if you really need to. If your
37 content type is recognized by the serializer, "request->body" will be
38 unserialized automatically, and it will be available as a standard
39 parameter.
40
41 For instance, if you call
42
43 curl -X POST -H 'Content-Type: application/json' -d '{"id":"bar"}' /foo
44
45 your "foo" route can do something like:
46
47 post "/foo" => {
48 my $id = param('id'); # gets "bar"
49 # ...
50 }
51
53 This module has been written by Alexis Sukrieh and Franck Cuny. See
54 the AUTHORS file that comes with this distribution for details.
55
57 This module is free software and is released under the same terms as
58 Perl itself.
59
61 See Dancer for details about the complete framework.
62
64 Dancer Core Developers
65
67 This software is copyright (c) 2010 by Alexis Sukrieh.
68
69 This is free software; you can redistribute it and/or modify it under
70 the same terms as the Perl 5 programming language system itself.
71
72
73
74perl v5.32.0 2020-07-28 Dancer::Serializer(3)