public function getPayload(string $key, $default = null)
    {
        if ($this->payload === null) {
            $contentType = $this->getHeader('Content-Type', '');
            if (!$contentType) {
                $contentType = $this->getHeader('Content-type');
            }

            if ($contentType) {
                $contentTypeParts = preg_split('/\s*[;,]\s*/', $contentType);
                $contentType = $contentTypeParts[0];
                $contentType = strtolower($contentType);
                if (isset($this->bodyParsers[$contentType])) {
                    $parser = $this->bodyParsers[$contentType];
                    $this->payload = $parser($this->body);
                }
            }
        }

        return $this->payload[$key] ?? $default;
    }
public function getPayload(string $key, $default = null)
    {
        if ($this->payload === null) {
            $contentType = $this->getHeader('Content-Type', '');
            if (!$contentType) {
                $contentType = $this->getHeader('Content-type');
            }

            if ($contentType) {
                $contentTypeParts = preg_split('/\s*[;,]\s*/', $contentType);
                $contentType = $contentTypeParts[0];
                $contentType = strtolower($contentType);
                if (isset($this->bodyParsers[$contentType])) {
                    $parser = $this->bodyParsers[$contentType];
                    $this->payload = $parser($this->body);
                }
            }
        }

        return $this->payload[$key] ?? $default;
    }
public function getPayload ( string $ key , $ default = null ) { if ( $ this -> payload === null ) { $ contentType = $ this -> getHeader ( 'Content-Type' , '' ) ; if ( ! $ contentType ) { $ contentType = $ this -> getHeader ( 'Content-type' ) ; } if ( $ contentType ) { $ contentTypeParts = preg_split ( '/\s*[;,]\s*/' , $ contentType ) ; $ contentType = $ contentTypeParts [ 0 ] ; $ contentType = strtolower ( $ contentType ) ; if ( isset ( $ this -> bodyParsers [ $ contentType ] ) ) { $ parser = $ this -> bodyParsers [ $ contentType ] ; $ this -> payload = $ parser ( $ this -> body ) ; } } } return $ this -> payload [ $ key ] ?? $ default ; }
get body param

@param $key string
@param null $default mixed
@return mixed|null
get body param