Chapter 4. APIs
Mason is more than just a templating system. It provides a framework for translating requests into output.[12] This framework has a number of class/object APIs worth knowing about. You certainly won’t need to use most of these methods very often, but you will probably want to use at least some of them in many of your Mason-based projects. This chapter documents those APIs. For a more concise reference to these methods, see Appendix B.
Request Class and Object API
The request object in Mason represents the context of the current request process. For example, it knows where in the component wrapping chain it is, what arguments have been passed to various component calls, if you’ve been bad or good, and so on. It also allows you to change that context in various ways, such as by calling another component or aborting the request.
The request API provides access to some of the most frequently used Mason features, particularly those relating to component calls, autohandlers, and aborting in the middle of a request.
Recall, as first mentioned in Chapter 2, that the
Mason request object is available in all components as
$m.
The request
class has only two class methods. The first,
HTML::Mason::Request->new( )
,
is intended for use by other Mason objects and is not documented for
external use. If you want to make a new request object, use the
make_subrequest( )
method provided by the request object, which is covered as part of the discussion of Mason’s subrequest mechanism ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access