Skip to main content

nexus-http

Core HTTP framework primitives: PSR-7/PSR-15 dispatcher, routing, middleware pipeline, response factories, attribute-driven handler DI, and the ParamResolver extension point.

What's in this package

Install

composer require nexus-actors/http

Quick example

src/Http/Handler/CreateOrderHandler.php
use Monadial\Nexus\Http\Handler\Attribute\FromActor;
use Monadial\Nexus\Http\Handler\Attribute\FromBody;
use Monadial\Nexus\Http\Response\Response;
use Monadial\Nexus\Core\Actor\ActorRef;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Message\ResponseInterface;

final class CreateOrderHandler
{
public function __construct(
#[FromActor('orders')] private readonly ActorRef $orders,
) {}

public function __invoke(
ServerRequestInterface $req,
#[FromBody] CreateOrderDto $dto,
): ResponseInterface {
$this->orders->tell(new PlaceOrder($dto));

return Response::created('/orders');
}
}

This package provides the primitives. The fluent application builder (HttpApplication, WsApplication, .get(), .post(), .middleware(), .actor()) lives in nexus-http-ws.

See also