Http Addon

The Http addon manages HTTP requests/responses, setting up hooks, processing routes, and adding themes.

Related: Http Addon Class

Docs

Most Http addon features are documented in other files. See Related Docs above.

  • Methods To Know
  • Additional Info
  • Hooks - The Http addon uses several hooks to modify the request. See Hooks Documentation for how to use hooks, and see Hooks Class for a list of available hooks.
  • Response Object - The Response object is passed to several of the hooks, and can be modified to change headers, content, and theme.
  • Request Object - The Request object represents an HTTP request and is passed to the REQUEST_STARTED hook.
  • Routes - Routes are handled by the Router addon. The Http addon calls the router to get available routes, and filters them if more than one route is returned.
  • Theme - The theme is a view, and is managed by the the Http addon or can be set on the Response object.

Methods To Know

See Http Addon Class for others.

for $http = \Lia\Addon\Http::from($lia);

  • $http->setTheme('vendor:namespace.view_name') set the name of the theme view.
  • $http->deliver(string $url, string $method): void literally just getResponse() and send_response()
  • $http->getResponse(string $url, string $method): \Lia\Obj\Response process a request and return a finished response object with theme applied. Triggers various hooks.
  • $http->send_response(\Lia\Obj\Response $response): void send the headers and the content of a response object, and trigger the post-response hooks. If $response->sendContent == false then headers send but content does not.

Note: Some method signatures in the actual code are not strongly typed, but will be eventually.

Additional Info

  • If a route is not found for the request, Http addon will try to find a matching route that has a trailing slash OR is lowercase, and then redirect to it automatically. (This functionality may be expanded in the future, and may be made optional in the future)