mirror of
https://github.com/danog/TelegramApiServer.git
synced 2024-11-30 04:19:13 +01:00
Upgrade amp http server
This commit is contained in:
parent
2b3d162bf3
commit
2fb2c3a9e0
106
composer.lock
generated
106
composer.lock
generated
@ -538,16 +538,16 @@
|
||||
},
|
||||
{
|
||||
"name": "amphp/http-client",
|
||||
"version": "v5.0.0-beta.11",
|
||||
"version": "v5.0.0-beta.12",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/amphp/http-client.git",
|
||||
"reference": "0fd30c4ff2231b044ead0e7a5d3aedafcbca59b1"
|
||||
"reference": "4a962fe1d96ca0ca956401f08eb3eb72e90e5d2b"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/amphp/http-client/zipball/0fd30c4ff2231b044ead0e7a5d3aedafcbca59b1",
|
||||
"reference": "0fd30c4ff2231b044ead0e7a5d3aedafcbca59b1",
|
||||
"url": "https://api.github.com/repos/amphp/http-client/zipball/4a962fe1d96ca0ca956401f08eb3eb72e90e5d2b",
|
||||
"reference": "4a962fe1d96ca0ca956401f08eb3eb72e90e5d2b",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -559,10 +559,8 @@
|
||||
"amphp/socket": "^2",
|
||||
"amphp/sync": "^2",
|
||||
"league/uri": "^6",
|
||||
"league/uri-components": "^2.4",
|
||||
"php": ">=8.1",
|
||||
"psr/http-message": "^1",
|
||||
"revolt/event-loop": "^1"
|
||||
"psr/http-message": "^1 | ^2"
|
||||
},
|
||||
"require-dev": {
|
||||
"amphp/file": "^3",
|
||||
@ -624,7 +622,7 @@
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/amphp/http-client/issues",
|
||||
"source": "https://github.com/amphp/http-client/tree/v5.0.0-beta.11"
|
||||
"source": "https://github.com/amphp/http-client/tree/v5.0.0-beta.12"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
@ -632,7 +630,7 @@
|
||||
"type": "github"
|
||||
}
|
||||
],
|
||||
"time": "2023-04-13T05:19:15+00:00"
|
||||
"time": "2023-08-05T15:21:21+00:00"
|
||||
},
|
||||
{
|
||||
"name": "amphp/http-client-cookies",
|
||||
@ -717,12 +715,12 @@
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/amphp/http-server.git",
|
||||
"reference": "b9f6a9e039dd5b9ecc224c6e46d1a410691bbdca"
|
||||
"reference": "33bd2a0c272e16cb51493f0aaabd11c7a9da73ef"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/amphp/http-server/zipball/b9f6a9e039dd5b9ecc224c6e46d1a410691bbdca",
|
||||
"reference": "b9f6a9e039dd5b9ecc224c6e46d1a410691bbdca",
|
||||
"url": "https://api.github.com/repos/amphp/http-server/zipball/33bd2a0c272e16cb51493f0aaabd11c7a9da73ef",
|
||||
"reference": "33bd2a0c272e16cb51493f0aaabd11c7a9da73ef",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -807,7 +805,7 @@
|
||||
"type": "github"
|
||||
}
|
||||
],
|
||||
"time": "2023-06-03T16:00:02+00:00"
|
||||
"time": "2023-07-31T23:21:23+00:00"
|
||||
},
|
||||
{
|
||||
"name": "amphp/http-server-form-parser",
|
||||
@ -893,30 +891,33 @@
|
||||
},
|
||||
{
|
||||
"name": "amphp/http-server-router",
|
||||
"version": "v2.0.0-beta.3",
|
||||
"version": "v2.0.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/amphp/http-server-router.git",
|
||||
"reference": "d08be2868ca5e0a0882b6149c3e2546b1e2b3a53"
|
||||
"reference": "8a166efa10bc3fc887a7a42b8a55c7b16bc9fc61"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/amphp/http-server-router/zipball/d08be2868ca5e0a0882b6149c3e2546b1e2b3a53",
|
||||
"reference": "d08be2868ca5e0a0882b6149c3e2546b1e2b3a53",
|
||||
"url": "https://api.github.com/repos/amphp/http-server-router/zipball/8a166efa10bc3fc887a7a42b8a55c7b16bc9fc61",
|
||||
"reference": "8a166efa10bc3fc887a7a42b8a55c7b16bc9fc61",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"amphp/amp": "^3",
|
||||
"amphp/cache": "^2",
|
||||
"amphp/http": "^2-dev",
|
||||
"amphp/http": "^2",
|
||||
"amphp/http-server": "^3",
|
||||
"amphp/socket": "^2",
|
||||
"nikic/fast-route": "^1",
|
||||
"php": ">=8.1"
|
||||
"php": ">=8.1",
|
||||
"psr/log": "^1|^2|^3"
|
||||
},
|
||||
"require-dev": {
|
||||
"amphp/log": "^2",
|
||||
"amphp/php-cs-fixer-config": "^2",
|
||||
"amphp/phpunit-util": "^3",
|
||||
"colinodell/psr-testlogger": "^1.2",
|
||||
"league/uri": "^6",
|
||||
"phpunit/phpunit": "^9",
|
||||
"psalm/phar": "^5.6"
|
||||
@ -948,7 +949,7 @@
|
||||
"email": "aaron@trowski.com"
|
||||
}
|
||||
],
|
||||
"description": "Router responder for Amp's HTTP server.",
|
||||
"description": "Routes to request handlers based on HTTP method and path for amphp/http-server.",
|
||||
"homepage": "https://github.com/amphp/http-server-router",
|
||||
"keywords": [
|
||||
"http",
|
||||
@ -957,7 +958,7 @@
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/amphp/http-server-router/issues",
|
||||
"source": "https://github.com/amphp/http-server-router/tree/v2.0.0-beta.3"
|
||||
"source": "https://github.com/amphp/http-server-router/tree/v2.0.0"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
@ -965,20 +966,20 @@
|
||||
"type": "github"
|
||||
}
|
||||
],
|
||||
"time": "2023-04-22T15:05:05+00:00"
|
||||
"time": "2023-08-05T19:16:57+00:00"
|
||||
},
|
||||
{
|
||||
"name": "amphp/log",
|
||||
"version": "v2.0.0-beta.2",
|
||||
"version": "v2.0.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/amphp/log.git",
|
||||
"reference": "f65226ffa4dfe0dd63805f2af31aced9ed27efb6"
|
||||
"reference": "bf1562b8a18a3f30efa069ed740f412ac70a8a6c"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/amphp/log/zipball/f65226ffa4dfe0dd63805f2af31aced9ed27efb6",
|
||||
"reference": "f65226ffa4dfe0dd63805f2af31aced9ed27efb6",
|
||||
"url": "https://api.github.com/repos/amphp/log/zipball/bf1562b8a18a3f30efa069ed740f412ac70a8a6c",
|
||||
"reference": "bf1562b8a18a3f30efa069ed740f412ac70a8a6c",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -1031,7 +1032,7 @@
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/amphp/log/issues",
|
||||
"source": "https://github.com/amphp/log/tree/v2.0.0-beta.2"
|
||||
"source": "https://github.com/amphp/log/tree/v2.0.0"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
@ -1039,7 +1040,7 @@
|
||||
"type": "github"
|
||||
}
|
||||
],
|
||||
"time": "2023-02-03T03:34:16+00:00"
|
||||
"time": "2023-08-05T18:59:54+00:00"
|
||||
},
|
||||
{
|
||||
"name": "amphp/mysql",
|
||||
@ -1397,16 +1398,16 @@
|
||||
},
|
||||
{
|
||||
"name": "amphp/process",
|
||||
"version": "v2.0.0",
|
||||
"version": "v2.0.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/amphp/process.git",
|
||||
"reference": "9c9247fe8283b22e00a254746bf822da4b0b5ea4"
|
||||
"reference": "a65d3bc1f36ef12d44df42a68f0f0643183f1052"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/amphp/process/zipball/9c9247fe8283b22e00a254746bf822da4b0b5ea4",
|
||||
"reference": "9c9247fe8283b22e00a254746bf822da4b0b5ea4",
|
||||
"url": "https://api.github.com/repos/amphp/process/zipball/a65d3bc1f36ef12d44df42a68f0f0643183f1052",
|
||||
"reference": "a65d3bc1f36ef12d44df42a68f0f0643183f1052",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -1453,7 +1454,7 @@
|
||||
"homepage": "https://amphp.org/process",
|
||||
"support": {
|
||||
"issues": "https://github.com/amphp/process/issues",
|
||||
"source": "https://github.com/amphp/process/tree/v2.0.0"
|
||||
"source": "https://github.com/amphp/process/tree/v2.0.1"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
@ -1461,7 +1462,7 @@
|
||||
"type": "github"
|
||||
}
|
||||
],
|
||||
"time": "2023-01-09T21:32:38+00:00"
|
||||
"time": "2023-01-15T16:00:57+00:00"
|
||||
},
|
||||
{
|
||||
"name": "amphp/redis",
|
||||
@ -2506,12 +2507,12 @@
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/danog/MadelineProto.git",
|
||||
"reference": "266370354708e850254e7db76822801026aeee6e"
|
||||
"reference": "28269b1b7631435f42f8be718004f7f0f9ab3f53"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/danog/MadelineProto/zipball/266370354708e850254e7db76822801026aeee6e",
|
||||
"reference": "266370354708e850254e7db76822801026aeee6e",
|
||||
"url": "https://api.github.com/repos/danog/MadelineProto/zipball/28269b1b7631435f42f8be718004f7f0f9ab3f53",
|
||||
"reference": "28269b1b7631435f42f8be718004f7f0f9ab3f53",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -2573,7 +2574,8 @@
|
||||
"ext-gmp": "Install the gmp extension to speed up authorization",
|
||||
"ext-openssl": "Install the openssl extension for faster crypto",
|
||||
"ext-pdo": "Install the pdo extension to store session data on MySQL",
|
||||
"ext-primemodule": "Install the primemodule and FFI extensions to speed up MadelineProto (https://prime.madelineproto.xyz)"
|
||||
"ext-primemodule": "Install the primemodule and FFI extensions to speed up MadelineProto (https://prime.madelineproto.xyz)",
|
||||
"ext-uv": "Install the uv extension to greatly speed up MadelineProto!"
|
||||
},
|
||||
"default-branch": true,
|
||||
"type": "project",
|
||||
@ -2619,7 +2621,7 @@
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/danog/MadelineProto/issues",
|
||||
"source": "https://github.com/danog/MadelineProto/tree/8.0.0-beta127"
|
||||
"source": "https://github.com/danog/MadelineProto/tree/8.0.0-beta130"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
@ -2627,7 +2629,7 @@
|
||||
"type": "github"
|
||||
}
|
||||
],
|
||||
"time": "2023-07-27T11:21:21+00:00"
|
||||
"time": "2023-08-07T07:04:07+00:00"
|
||||
},
|
||||
{
|
||||
"name": "danog/primemodule",
|
||||
@ -2682,16 +2684,16 @@
|
||||
},
|
||||
{
|
||||
"name": "danog/tg-file-decoder",
|
||||
"version": "0.1.12",
|
||||
"version": "0.1.13",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/danog/tg-file-decoder.git",
|
||||
"reference": "fd9827e7af8f3b47dc6db4b1c12bfeb6654dde4f"
|
||||
"reference": "5cdb05816aad20583592635eddd90e9c6aae8930"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/danog/tg-file-decoder/zipball/fd9827e7af8f3b47dc6db4b1c12bfeb6654dde4f",
|
||||
"reference": "fd9827e7af8f3b47dc6db4b1c12bfeb6654dde4f",
|
||||
"url": "https://api.github.com/repos/danog/tg-file-decoder/zipball/5cdb05816aad20583592635eddd90e9c6aae8930",
|
||||
"reference": "5cdb05816aad20583592635eddd90e9c6aae8930",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -2733,7 +2735,7 @@
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/danog/tg-file-decoder/issues",
|
||||
"source": "https://github.com/danog/tg-file-decoder/tree/0.1.12"
|
||||
"source": "https://github.com/danog/tg-file-decoder/tree/0.1.13"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
@ -2741,7 +2743,7 @@
|
||||
"type": "github"
|
||||
}
|
||||
],
|
||||
"time": "2022-11-16T16:22:45+00:00"
|
||||
"time": "2023-08-05T21:04:20+00:00"
|
||||
},
|
||||
{
|
||||
"name": "dasprid/enum",
|
||||
@ -3895,16 +3897,16 @@
|
||||
},
|
||||
{
|
||||
"name": "revolt/event-loop",
|
||||
"version": "v1.0.2",
|
||||
"version": "v1.0.3",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/revoltphp/event-loop.git",
|
||||
"reference": "b018d0ff141636d69a8054194675fe0050cf3aa9"
|
||||
"reference": "0fe2d31e1cddd26664e55d383d3d5da613334c03"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/revoltphp/event-loop/zipball/b018d0ff141636d69a8054194675fe0050cf3aa9",
|
||||
"reference": "b018d0ff141636d69a8054194675fe0050cf3aa9",
|
||||
"url": "https://api.github.com/repos/revoltphp/event-loop/zipball/0fe2d31e1cddd26664e55d383d3d5da613334c03",
|
||||
"reference": "0fe2d31e1cddd26664e55d383d3d5da613334c03",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -3961,9 +3963,9 @@
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/revoltphp/event-loop/issues",
|
||||
"source": "https://github.com/revoltphp/event-loop/tree/v1.0.2"
|
||||
"source": "https://github.com/revoltphp/event-loop/tree/v1.0.3"
|
||||
},
|
||||
"time": "2023-07-20T20:16:11+00:00"
|
||||
"time": "2023-07-29T17:07:12+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/polyfill-ctype",
|
||||
|
@ -11,9 +11,10 @@ use TelegramApiServer\Controllers\ApiController;
|
||||
use TelegramApiServer\Controllers\EventsController;
|
||||
use TelegramApiServer\Controllers\LogController;
|
||||
use TelegramApiServer\Controllers\SystemController;
|
||||
use TelegramApiServer\Logger;
|
||||
use TelegramApiServer\MadelineProtoExtensions\ApiExtensions;
|
||||
use TelegramApiServer\MadelineProtoExtensions\SystemApiExtensions;
|
||||
use function Amp\Http\Server\Middleware\stack;
|
||||
use function Amp\Http\Server\Middleware\stackMiddleware;
|
||||
|
||||
class Router
|
||||
{
|
||||
@ -21,7 +22,11 @@ class Router
|
||||
|
||||
public function __construct(SocketHttpServer $server, ErrorHandler $errorHandler)
|
||||
{
|
||||
$this->router = new \Amp\Http\Server\Router($server, $errorHandler);
|
||||
$this->router = new \Amp\Http\Server\Router(
|
||||
httpServer: $server,
|
||||
logger: Logger::getInstance(),
|
||||
errorHandler: $errorHandler,
|
||||
);
|
||||
$this->setRoutes();
|
||||
$this->setFallback();
|
||||
}
|
||||
@ -41,10 +46,10 @@ class Router
|
||||
private function setRoutes(): void
|
||||
{
|
||||
$authorization = new Authorization();
|
||||
$apiHandler = stack(ApiController::getRouterCallback(ApiExtensions::class), $authorization);
|
||||
$systemApiHandler = stack(SystemController::getRouterCallback(SystemApiExtensions::class), $authorization);
|
||||
$eventsHandler = stack(EventsController::getRouterCallback(), $authorization);
|
||||
$logHandler = stack(LogController::getRouterCallback(), $authorization);
|
||||
$apiHandler = stackMiddleware(ApiController::getRouterCallback(ApiExtensions::class), $authorization);
|
||||
$systemApiHandler = stackMiddleware(SystemController::getRouterCallback(SystemApiExtensions::class), $authorization);
|
||||
$eventsHandler = stackMiddleware(EventsController::getRouterCallback(), $authorization);
|
||||
$logHandler = stackMiddleware(LogController::getRouterCallback(), $authorization);
|
||||
|
||||
foreach (['GET', 'POST'] as $method) {
|
||||
$this->router->addRoute($method, '/api/{method}[/]', $apiHandler);
|
||||
|
Loading…
Reference in New Issue
Block a user