Web::M...Entity(3pm)
π Web::M...Entity π
okay so bestie, this is Web::MREST::Entity, a chunk of the Perl user-contributed documentation, page 3pm. She's all about handling request entities and response entities β like, the actual stuff going in and out. she's lowkey iconic and you're gonna learn her. π
β¨ NAME β¨
Web::MREST::Entity β Methods for dealing with request, response entities π
πΈ SYNOPSIS πΈ
Methods for dealing with request, response entities
that's it. that's the synopsis. she's mysterious like that. β¨
π¦ METHODS π¦
get_acceptable_content_type_handler
so the method you use to process the request entity β aka the "acceptable content type handler" β gets set in content_types_accepted. here's the tea tho: Web::Machine only calls that method on PUT requests, and on those POST requests where post_is_create is true. π
but wait, what about the POST requests where post_is_create is false?? on those, we have to call it ourselves, bestie. no one else is coming to save us. and to do that, we need a way to actually get to it. that's literally this method. π
content_types_provided
Web::Machine calls this routine to figure out how to generate the response body for GET requests. no cap. (and just so you know β it is not called for PUT, POST, or DELETE requests. she's exclusive. π)
the return value has the following format:
[
{ 'text/html' => 'method_for_html' },
{ 'application/json' => 'method_for_json' },
{ 'other/mime' => 'method_for_other_mime' },
]
see how that's a list of tuples? the key is a media type and the value is the name of a method. and the vibe check here: the first tuple is taken as the default. so put your fave first, iykyk. π«Ά
mrest_generate_response_html
normally, clients talk to the server via _render_response_json, but humans need HTML. we're not built different, we just need readability. π
this method takes the server's JSON response and wraps it up in a nice package β a little gift, if you will. π the return value from this method becomes the response entity. periodt.
content_types_accepted
Web::Machine calls this routine to determine how to handle the request body (e.g. in PUT requests). that's the whole job. she's efficient. π
mrest_process_request_json
PUT and POST requests may contain a request body β and this right here is the "handler function" where we process those requests. slash slay.
we associate this function with 'application/json' via content_types_accepted. matching them up like a group chat flirt. π
mrest_process_request
used to call the request handler manually in cases when Web::Machine does not call it for us. sometimes you gotta be your own main character. π₯
mrest_generate_response_json
okay this one is a whole three-step routine, let's go:
- first, run pass 2 of the resource handler, which is expected to return an
App::CELL::Statusobject. - second, push that object onto the context.
- third, convert that object into JSON and push the JSON onto the context, too. β¨
then return the JSON representation of the App::CELL::Status object β this becomes the HTTP response entity. and that's the whole ritual. π―οΈ
mrest_generate_response
this should somehow get the response handler and run it. that's the instruction, bestie. that's the whole thing. go get it and run it. πβοΈπ¨
π and that's the page, fr fr. go forth and handle those entities. π
π§ made with perl v5.40.1, dated 2025-06-21, straight from the User Contributed Perl Documentation. byeee bestie, mwah π ππΈ
π¦ where this page comes from
- ubuntu resolute: libweb-mrest-perl 0.290-2 Β· BSD-3-Clause
- ubuntu stonking: libweb-mrest-perl 0.290-2 Β· BSD-3-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms