class Routes implements ExtenderInterface

Methods

__construct(string $appName)

No description

get(string $path, string $name, callable|string $handler)

Add a GET route.

post(string $path, string $name, callable|string $handler)

Add a POST route.

put(string $path, string $name, callable|string $handler)

Add a PUT route.

patch(string $path, string $name, callable|string $handler)

Add a PATCH route.

delete(string $path, string $name, callable|string $handler)

Add a DELETE route.

remove(string $name)

Remove an existing route.

void
extend( Container $container, Extension|null $extension = null)

No description

Details

__construct(string $appName)

Parameters

string $appName : Name of the app (api, forum, admin).

Routes get(string $path, string $name, callable|string $handler)

Add a GET route.

Parameters

string $path : The path of the route
string $name : The name of the route, must be unique.
callable|string $handler : ::class attribute of the controller class, or a closure. If the handler is a controller class, it should implement \Psr\Http\Server\RequestHandlerInterface, or extend one of the Flarum Api controllers within \Flarum\Api\Controller. The handler should accept: - \Psr\Http\Message\ServerRequestInterface $request The handler should return: - \Psr\Http\Message\ResponseInterface $response

Return Value

Routes

Routes post(string $path, string $name, callable|string $handler)

Add a POST route.

Parameters

string $path : The path of the route
string $name : The name of the route, must be unique.
callable|string $handler : ::class attribute of the controller class, or a closure. If the handler is a controller class, it should implement \Psr\Http\Server\RequestHandlerInterface, or extend one of the Flarum Api controllers within \Flarum\Api\Controller. The handler should accept: - \Psr\Http\Message\ServerRequestInterface $request The handler should return: - \Psr\Http\Message\ResponseInterface $response

Return Value

Routes

Routes put(string $path, string $name, callable|string $handler)

Add a PUT route.

Parameters

string $path : The path of the route
string $name : The name of the route, must be unique.
callable|string $handler : ::class attribute of the controller class, or a closure. If the handler is a controller class, it should implement \Psr\Http\Server\RequestHandlerInterface, or extend one of the Flarum Api controllers within \Flarum\Api\Controller. The handler should accept: - \Psr\Http\Message\ServerRequestInterface $request The handler should return: - \Psr\Http\Message\ResponseInterface $response

Return Value

Routes

Routes patch(string $path, string $name, callable|string $handler)

Add a PATCH route.

Parameters

string $path : The path of the route
string $name : The name of the route, must be unique.
callable|string $handler : ::class attribute of the controller class, or a closure. If the handler is a controller class, it should implement \Psr\Http\Server\RequestHandlerInterface, or extend one of the Flarum Api controllers within \Flarum\Api\Controller. The handler should accept: - \Psr\Http\Message\ServerRequestInterface $request The handler should return: - \Psr\Http\Message\ResponseInterface $response

Return Value

Routes

Routes delete(string $path, string $name, callable|string $handler)

Add a DELETE route.

Parameters

string $path : The path of the route
string $name : The name of the route, must be unique.
callable|string $handler : ::class attribute of the controller class, or a closure. If the handler is a controller class, it should implement \Psr\Http\Server\RequestHandlerInterface, or extend one of the Flarum Api controllers within \Flarum\Api\Controller. The handler should accept: - \Psr\Http\Message\ServerRequestInterface $request The handler should return: - \Psr\Http\Message\ResponseInterface $response

Return Value

Routes

Routes remove(string $name)

Remove an existing route.

Necessary before overriding a route.

Parameters

string $name : The name of the route.

Return Value

Routes

void extend( Container $container, Extension|null $extension = null)

Parameters

Container $container
Extension|null $extension

Return Value

void