.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.42) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "Web::MREST::Dispatch 3pm" .TH Web::MREST::Dispatch 3pm "2022-09-21" "perl v5.34.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" App::MREST::Dispatch \- Resource handlers .SH "DESCRIPTION" .IX Header "DESCRIPTION" Your application should not call any of the routines in this module directly. They are called by Web::MREST::Resource during the course of request processing. What your application can do is provide its own resource handlers. .PP The resource handlers are called as ordinary functions with a sole argument: the \s-1MREST\s0 context. .SH "INITIALIZATION/RESOURCE DEFINITIONS" .IX Header "INITIALIZATION/RESOURCE DEFINITIONS" In this section we provide definitions of all resources handled by this module. These are picked up by Web::MREST::InitRouter. .PP This resource is the parent of all resources that do not specify a parent in their resource definition. \&\s-1EOH\s0 }, .PP .Vb 11 \& # bugreport \& \*(Aqbugreport\*(Aq => \& { \& parent => \*(Aq/\*(Aq, \& handler => { \& GET => \*(Aqhandler_bugreport\*(Aq, \& }, \& cli => \*(Aqbugreport\*(Aq, \& description => \*(AqDisplay instructions for reporting bugs in Web::MREST\*(Aq, \& documentation => <<\*(AqEOH\*(Aq, \&=pod .Ve .PP Returns a \s-1JSON\s0 structure containing instructions for reporting bugs. \&\s-1EOH\s0 }, .PP .Vb 11 \& # configinfo \& \*(Aqconfiginfo\*(Aq => \& { \& parent => \*(Aq/\*(Aq, \& handler => { \& GET => \*(Aqhandler_configinfo\*(Aq, \& }, \& cli => \*(Aqconfiginfo\*(Aq, \& description => \*(AqDisplay information about Web::MREST configuration\*(Aq, \& documentation => <<\*(AqEOH\*(Aq, \&=pod .Ve .PP Returns a list of directories that were scanned for configuration files. \&\s-1EOH\s0 }, .PP .Vb 9 \& # docu \& \*(Aqdocu\*(Aq => \& { \& parent => \*(Aq/\*(Aq, \& handler => \*(Aqhandler_noop\*(Aq, \& cli => \*(Aqdocu\*(Aq, \& description => \*(AqAccess on\-line documentation (via POST to appropriate subresource)\*(Aq, \& documentation => <<\*(AqEOH\*(Aq, \&=pod .Ve .PP This resource provides access to on-line documentation through its subresources: 'docu/pod', 'docu/html', and 'docu/text'. .PP To get documentation on a resource, send a \s-1POST\s0 reqeuest for one of these subresources, including the resource name in the request entity as a bare \s-1JSON\s0 string (i.e. in double quotes). \&\s-1EOH\s0 }, .PP .Vb 11 \& # docu/pod \& \*(Aqdocu/pod\*(Aq => \& { \& parent => \*(Aqdocu\*(Aq, \& handler => { \& POST => \*(Aqhandler_docu\*(Aq, \& }, \& cli => \*(Aqdocu pod $RESOURCE\*(Aq, \& description => \*(AqDisplay POD documentation of a resource\*(Aq, \& documentation => <<\*(AqEOH\*(Aq, \&=pod .Ve .PP This resource provides access to on-line help documentation in \s-1POD\s0 format. It expects to find a resource name (e.g. \*(L"employee/eid/:eid\*(R" including the double-quotes, and without leading or trailing slash) in the request body. It returns a string containing the \s-1POD\s0 source code of the resource documentation. \&\s-1EOH\s0 }, .PP .Vb 11 \& # docu/html \& \*(Aqdocu/html\*(Aq => \& { \& parent => \*(Aqdocu\*(Aq, \& handler => { \& POST => \*(Aqhandler_docu\*(Aq, \& }, \& cli => \*(Aqdocu html $RESOURCE\*(Aq, \& description => \*(AqDisplay HTML documentation of a resource\*(Aq, \& documentation => <<\*(AqEOH\*(Aq, \&=pod .Ve .PP This resource provides access to on-line help documentation. It expects to find a resource name (e.g. \*(L"employee/eid/:eid\*(R" including the double-quotes, and without leading or trailing slash) in the request body. It generates \s-1HTML\s0 from the resource documentation's \s-1POD\s0 source code. \&\s-1EOH\s0 }, .PP .Vb 11 \& # docu/text \& \*(Aqdocu/text\*(Aq => \& { \& parent => \*(Aqdocu\*(Aq, \& handler => { \& POST => \*(Aqhandler_docu\*(Aq, \& }, \& cli => \*(Aqdocu text $RESOURCE\*(Aq, \& description => \*(AqDisplay resource documentation in plain text\*(Aq, \& documentation => <<\*(AqEOH\*(Aq, \&=pod .Ve .PP This resource provides access to on-line help documentation. It expects to find a resource name (e.g. \*(L"employee/eid/:eid\*(R" including the double-quotes, and without leading or trailing slash) in the request body. It returns a plain text rendering of the \s-1POD\s0 source of the resource documentation. \&\s-1EOH\s0 }, .PP .Vb 11 \& # echo \& \*(Aqecho\*(Aq => \& { \& parent => \*(Aq/\*(Aq, \& handler => { \& POST => \*(Aqhandler_echo\*(Aq, \& }, \& cli => \*(Aqecho [$JSON]\*(Aq, \& description => \*(AqEcho the request body\*(Aq, \& documentation => <<\*(AqEOH\*(Aq, \&=pod .Ve .PP This resource simply takes whatever content body was sent and echoes it back in the response body. \&\s-1EOH\s0 }, .PP .Vb 9 \& # noop \& \*(Aqnoop\*(Aq => \& { \& parent => \*(Aq/\*(Aq, \& handler => \*(Aqhandler_noop\*(Aq, \& cli => \*(Aqnoop\*(Aq, \& description => \*(AqA resource that does nothing\*(Aq, \& documentation => <<\*(AqEOH\*(Aq, \&=pod .Ve .PP Regardless of anything, this resource does nothing at all. \&\s-1EOH\s0 }, .PP .Vb 10 \& # param/:type/:param \& \*(Aqparam/:type/:param\*(Aq => \& { \& parent => \*(Aq/\*(Aq, \& handler => { \& \*(AqGET\*(Aq => \*(Aqhandler_param\*(Aq, \& \*(AqPUT\*(Aq => \*(Aqhandler_param\*(Aq, \& \*(AqDELETE\*(Aq => \*(Aqhandler_param\*(Aq, \& }, \& cli => { \& \*(AqGET\*(Aq => \*(Aqparam $TYPE $PARAM\*(Aq, \& \*(AqPUT\*(Aq => \*(Aqparam $TYPE $PARAM $VALUE\*(Aq, \& \*(AqDELETE\*(Aq => \*(Aqparam $TYPE $PARAM\*(Aq, \& }, \& description => { \& \*(AqGET\*(Aq => \*(AqDisplay value of a meta/core/site parameter\*(Aq, \& \*(AqPUT\*(Aq => \*(AqSet value of a parameter (meta only)\*(Aq, \& \*(AqDELETE\*(Aq => \*(AqDelete a parameter (meta only)\*(Aq, \& }, \& documentation => <<\*(AqEOH\*(Aq, \&=pod .Ve .PP This resource can be used to look up (\s-1GET\s0) meta, core, and site parameters, as well as to set (\s-1PUT\s0) and delete (\s-1DELETE\s0) meta parameters. \&\s-1EOH\s0 validations => { 'type' => qr/^(meta)|(core)|(site)$/, 'param' => qr/^[[:alnum:]_][[:alnum:]_\-]+$/, }, }, .PP .Vb 8 \& # test/?:specs \& \*(Aqtest/?:specs\*(Aq => \& { \& parent => \*(Aq/\*(Aq, \& handler => \*(Aqhandler_test\*(Aq, \& cli => \*(Aqtest [$SPECS]\*(Aq, \& description => "Resources for testing resource handling semantics", \& }, \& \& # version \& \*(Aqversion\*(Aq => \& { \& parent => \*(Aq/\*(Aq, \& handler => { \& GET => \*(Aqhandler_version\*(Aq, \& }, \& cli => \*(Aqversion\*(Aq, \& description => \*(AqDisplay application name and version\*(Aq, \& documentation => <<\*(AqEOH\*(Aq, \&=pod .Ve .PP Shows the software version running on the present instance. The version displayed is taken from the \f(CW$VERSION\fR package variable of the package specified in the \&\f(CW\*(C`MREST_APPLICATION_MODULE\*(C'\fR site parameter. \&\s-1EOH\s0 }, .PP .Vb 1 \& }; .Ve .SH "FUNCTIONS" .IX Header "FUNCTIONS" .SS "init_router" .IX Subsection "init_router" Initialize (populate) the router. Called from Resource.pm when the first request comes waltzing in. .SS "_first_pass_always_exists" .IX Subsection "_first_pass_always_exists" Boilerplate code for use in handlers of resources that always exist .SS "handler_bugreport" .IX Subsection "handler_bugreport" Handler for the \f(CW\*(C`bugreport\*(C'\fR resource. .SS "handler_configinfo" .IX Subsection "handler_configinfo" Handler for the \f(CW\*(C`configinfo\*(C'\fR resource. .SS "handler_docu" .IX Subsection "handler_docu" The definition of resource \f(CW$docu_resource\fR lacks a 'documentation' property \&\s-1EOH\s0 # if they want \s-1POD,\s0 give them \s-1POD\s0; if they want \s-1HTML,\s0 give them \s-1HTML,\s0 etc. if ( \f(CW$resource_name\fR eq 'docu/pod' ) { \f(CW$pl\fR\->{'format'} = '\s-1POD\s0'; \f(CW$pl\fR\->{'documentation'} = \f(CW$docs\fR; } elsif ( \f(CW$resource_name\fR eq 'docu/html' ) { \f(CW$pl\fR\->{'format'} = '\s-1HTML\s0'; \f(CW$pl\fR\->{'documentation'} = pod_to_html( \f(CW$docs\fR ); } else { # fall back to plain text \f(CW$pl\fR\->{'format'} = 'text'; \f(CW$pl\fR\->{'documentation'} = pod_to_text( \f(CW$docs\fR ); } return \f(CW$CELL\fR\->status_ok( '\s-1MREST_DISPATCH_ONLINE_DOCUMENTATION\s0', payload => \f(CW$pl\fR ); } .SS "handler_echo" .IX Subsection "handler_echo" Echo request body back in the response .SS "handler_param" .IX Subsection "handler_param" Handler for 'param/:type/:param' resource. .SS "handler_noop" .IX Subsection "handler_noop" Generalized handler for resources that don't do anything. .SS "handler_test" .IX Subsection "handler_test" The only purpose of this resource is testing/demonstration of request handling. .SS "handler_version" .IX Subsection "handler_version" Handler for the \f(CW\*(C`version\*(C'\fR resource.