---
name: "Web::MREST::Entity"
section: "3pm"
platform: "linux"
package: "libweb-mrest-perl"
version: "0.290-1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/Web::MREST::Entity"
---

# Web::MREST::Entity(3pm)

Methods for dealing with request, response entities

## NAME

Web::MREST::Entity - Methods for dealing with request, response entities

## SYNOPSIS

Methods for dealing with request, response entities

## METHODS

### get\_acceptable\_content\_type\_handler

The method to use to process the request entity (i.e, the "acceptable content type handler") is set in content\_types\_accepted. Web::Machine only calls the method on PUT requests and those POST requests for which post\_is\_create is true. On POST requests where post\_is\_create is false, we have to call it ourselves, and for that we need a way to get to it.

### content\_types\_provided

Web::Machine calls this routine to determine how to generate the response body GET requests. (It is not called for PUT, POST, or DELETE requests.)

The return value has the following format:

```
    [
        { 'text/html' => 'method_for_html' },
        { 'application/json' => 'method_for_json' },
        { 'other/mime' => 'method_for_other_mime' },
    ]
```

As you can see, this is a list of tuples. The key is a media type and the  value is the name of a method. The first tuple is taken as the default.

### mrest\_generate\_response\_html

Normally, clients will communicate with the server via '\_render\_response\_json', but humans need HTML. This method takes the server's JSON response and wraps it up in a nice package.  The return value from this method becomes the response entity.

### content\_types\_accepted

Web::Machine calls this routine to determine how to handle the request body (e.g. in PUT requests).

### mrest\_process\_request\_json

PUT and POST requests may contain a request body. This is the "handler function" where we process those requests.

We associate this function with 'application/json' via `"content_types_accepted"`.

### mrest\_process\_request

Used to call the request handler manually in cases when Web::Machine does not call it for us.

### mrest\_generate\_response\_json

First, run pass 2 of the resource handler, which is expected to return an App::CELL::Status object. Second, push that object onto the context. Third, convert that object into JSON and push the JSON onto the context, too. Return the JSON representation of the App::CELL::Status object - this becomes the HTTP response entity.

### mrest\_generate\_response

This should somehow get the response handler and run it.
