benycode/psr-response-renderer

There is no license information available for the latest version (v1.0.0) of this package.

Psr7 response renderer for the microservices

v1.0.0 2023-02-13 18:05 UTC

This package is not auto-updated.

Last update: 2024-11-05 23:52:23 UTC


README

Psr 7 response renderer

Table of contents

Install

Via Composer

$ composer require benycode/psr-response-renderer

Usage

json renderer:

use Psr\Http\Message\ResponseInterface;

	....
	public function __construct(
        private readonly JsonRenderer $renderer,
    ) {
    }
	....
	
	public function __invoke(
        ServerRequestInterface $request,
        ResponseInterface $response,
    ): ResponseInterface {
		return $this->renderer
            ->response($response)
            ->create([
                'message' => 'created',
            ])
            ->withStatus(StatusCodeInterface::STATUS_CREATED)
        ;
	}